diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-08 14:30:41 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2014-08-12 13:49:54 +0200 |
commit | ab0a50979b9eb4dfa3320eff7e187e41efedf7a9 (patch) | |
tree | 498dfb8a97ff3361a9f7486863a52bb4e26bb898 /chromium/third_party/ffmpeg/libavutil | |
parent | 4ce69f7403811819800e7c5ae1318b2647e778d1 (diff) |
Update Chromium to beta version 37.0.2062.68
Change-Id: I188e3b5aff1bec75566014291b654eb19f5bc8ca
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'chromium/third_party/ffmpeg/libavutil')
84 files changed, 3261 insertions, 480 deletions
diff --git a/chromium/third_party/ffmpeg/libavutil/Makefile b/chromium/third_party/ffmpeg/libavutil/Makefile index 89708fc0af1..a345024722a 100644 --- a/chromium/third_party/ffmpeg/libavutil/Makefile +++ b/chromium/third_party/ffmpeg/libavutil/Makefile @@ -19,6 +19,7 @@ HEADERS = adler32.h \ common.h \ cpu.h \ crc.h \ + downmix_info.h \ error.h \ eval.h \ fifo.h \ @@ -31,6 +32,7 @@ HEADERS = adler32.h \ intreadwrite.h \ lfg.h \ log.h \ + macros.h \ mathematics.h \ md5.h \ mem.h \ @@ -42,6 +44,7 @@ HEADERS = adler32.h \ pixdesc.h \ pixfmt.h \ random_seed.h \ + replaygain.h \ rational.h \ ripemd.h \ samplefmt.h \ @@ -79,12 +82,14 @@ OBJS = adler32.o \ cpu.o \ crc.o \ des.o \ + downmix_info.o \ error.o \ eval.o \ fifo.o \ file.o \ file_open.o \ float_dsp.o \ + fixed_dsp.o \ frame.o \ hash.o \ hmac.o \ @@ -148,15 +153,18 @@ TESTPROGS = adler32 \ eval \ file \ fifo \ + float_dsp \ hmac \ lfg \ lls1 \ lls2 \ + log \ md5 \ murmur3 \ opt \ pca \ parseutils \ + pixdesc \ random_seed \ rational \ ripemd \ diff --git a/chromium/third_party/ffmpeg/libavutil/aarch64/Makefile b/chromium/third_party/ffmpeg/libavutil/aarch64/Makefile new file mode 100644 index 00000000000..5613813ba8c --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/aarch64/Makefile @@ -0,0 +1,4 @@ +OBJS += aarch64/cpu.o \ + aarch64/float_dsp_init.o \ + +NEON-OBJS += aarch64/float_dsp_neon.o diff --git a/chromium/third_party/ffmpeg/libavutil/aarch64/asm.S b/chromium/third_party/ffmpeg/libavutil/aarch64/asm.S new file mode 100644 index 00000000000..51850ec7ba6 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/aarch64/asm.S @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" + +#ifdef __ELF__ +# define ELF +#else +# define ELF // +#endif + +.macro function name, export=0, align=2 + .macro endfunc +ELF .size \name, . - \name + .endfunc + .purgem endfunc + .endm + .text + .align \align + .if \export + .global EXTERN_ASM\name +ELF .type EXTERN_ASM\name, %function + .func EXTERN_ASM\name +EXTERN_ASM\name: + .else +ELF .type \name, %function + .func \name +\name: + .endif +.endm + +.macro const name, align=2 + .macro endconst +ELF .size \name, . - \name + .purgem endconst + .endm + .section .rodata + .align \align +\name: +.endm + +.macro movrel rd, val +#if CONFIG_PIC + adrp \rd, #:pg_hi21:\val + add \rd, \rd, #:lo12:\val +#else + ldr \rd, =\val +#endif +.endm + +#define GLUE(a, b) a ## b +#define JOIN(a, b) GLUE(a, b) +#define X(s) JOIN(EXTERN_ASM, s) diff --git a/chromium/third_party/ffmpeg/libavutil/aarch64/bswap.h b/chromium/third_party/ffmpeg/libavutil/aarch64/bswap.h new file mode 100644 index 00000000000..1e735c52cf7 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/aarch64/bswap.h @@ -0,0 +1,50 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AARCH64_BSWAP_H +#define AVUTIL_AARCH64_BSWAP_H + +#include <stdint.h> +#include "config.h" +#include "libavutil/attributes.h" + +#if HAVE_INLINE_ASM + +#define av_bswap16 av_bswap16 +static av_always_inline av_const unsigned av_bswap16(unsigned x) +{ + __asm__("rev16 %w0, %w0" : "+r"(x)); + return x; +} + +#define av_bswap32 av_bswap32 +static av_always_inline av_const uint32_t av_bswap32(uint32_t x) +{ + __asm__("rev %w0, %w0" : "+r"(x)); + return x; +} + +#define av_bswap64 av_bswap64 +static av_always_inline av_const uint64_t av_bswap64(uint64_t x) +{ + __asm__("rev %0, %0" : "+r"(x)); + return x; +} + +#endif /* HAVE_INLINE_ASM */ +#endif /* AVUTIL_AARCH64_BSWAP_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/aarch64/cpu.c b/chromium/third_party/ffmpeg/libavutil/aarch64/cpu.c new file mode 100644 index 00000000000..8ef077aaea3 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/aarch64/cpu.c @@ -0,0 +1,28 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/cpu.h" +#include "libavutil/cpu_internal.h" +#include "config.h" + +int ff_get_cpu_flags_aarch64(void) +{ + return AV_CPU_FLAG_ARMV8 * HAVE_ARMV8 | + AV_CPU_FLAG_NEON * HAVE_NEON | + AV_CPU_FLAG_VFP * HAVE_VFP; +} diff --git a/chromium/third_party/ffmpeg/libavutil/aarch64/cpu.h b/chromium/third_party/ffmpeg/libavutil/aarch64/cpu.h new file mode 100644 index 00000000000..cf1b9cc5168 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/aarch64/cpu.h @@ -0,0 +1,30 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AARCH64_CPU_H +#define AVUTIL_AARCH64_CPU_H + +#include "config.h" +#include "libavutil/cpu.h" +#include "libavutil/cpu_internal.h" + +#define have_armv8(flags) CPUEXT(flags, ARMV8) +#define have_neon(flags) CPUEXT(flags, NEON) +#define have_vfp(flags) CPUEXT(flags, VFP) + +#endif /* AVUTIL_AARCH64_CPU_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/aarch64/float_dsp_init.c b/chromium/third_party/ffmpeg/libavutil/aarch64/float_dsp_init.c new file mode 100644 index 00000000000..4325071821c --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/aarch64/float_dsp_init.c @@ -0,0 +1,69 @@ +/* + * ARM NEON optimised Float DSP functions + * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <stdint.h> + +#include "libavutil/attributes.h" +#include "libavutil/cpu.h" +#include "libavutil/float_dsp.h" +#include "cpu.h" + +void ff_vector_fmul_neon(float *dst, const float *src0, const float *src1, + int len); + +void ff_vector_fmac_scalar_neon(float *dst, const float *src, float mul, + int len); + +void ff_vector_fmul_scalar_neon(float *dst, const float *src, float mul, + int len); + +void ff_vector_dmul_scalar_neon(double *dst, const double *src, double mul, + int len); + +void ff_vector_fmul_window_neon(float *dst, const float *src0, + const float *src1, const float *win, int len); + +void ff_vector_fmul_add_neon(float *dst, const float *src0, const float *src1, + const float *src2, int len); + +void ff_vector_fmul_reverse_neon(float *dst, const float *src0, + const float *src1, int len); + +void ff_butterflies_float_neon(float *v1, float *v2, int len); + +float ff_scalarproduct_float_neon(const float *v1, const float *v2, int len); + +av_cold void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp) +{ + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) { + fdsp->butterflies_float = ff_butterflies_float_neon; + fdsp->scalarproduct_float = ff_scalarproduct_float_neon; + fdsp->vector_dmul_scalar = ff_vector_dmul_scalar_neon; + fdsp->vector_fmul = ff_vector_fmul_neon; + fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_neon; + fdsp->vector_fmul_add = ff_vector_fmul_add_neon; + fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_neon; + fdsp->vector_fmul_scalar = ff_vector_fmul_scalar_neon; + fdsp->vector_fmul_window = ff_vector_fmul_window_neon; + } +} diff --git a/chromium/third_party/ffmpeg/libavutil/aarch64/float_dsp_neon.S b/chromium/third_party/ffmpeg/libavutil/aarch64/float_dsp_neon.S new file mode 100644 index 00000000000..02d790c0cc6 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/aarch64/float_dsp_neon.S @@ -0,0 +1,202 @@ +/* + * ARM NEON optimised Float DSP functions + * Copyright (c) 2008 Mans Rullgard <mans@mansr.com> + * Copyright (c) 2014 Janne Grunau <janne-libav@jannau.net> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "asm.S" + +function ff_vector_fmul_neon, export=1 +1: subs w3, w3, #16 + ld1 {v0.4S, v1.4S}, [x1], #32 + ld1 {v2.4S, v3.4S}, [x1], #32 + ld1 {v4.4S, v5.4S}, [x2], #32 + ld1 {v6.4S, v7.4S}, [x2], #32 + fmul v16.4S, v0.4S, v4.4S + fmul v17.4S, v1.4S, v5.4S + fmul v18.4S, v2.4S, v6.4S + fmul v19.4S, v3.4S, v7.4S + st1 {v16.4S, v17.4S}, [x0], #32 + st1 {v18.4S, v19.4S}, [x0], #32 + b.ne 1b + ret +endfunc + +function ff_vector_fmac_scalar_neon, export=1 + mov x3, #-32 +1: subs w2, w2, #16 + ld1 {v16.4S, v17.4S}, [x0], #32 + ld1 {v18.4S, v19.4S}, [x0], x3 + ld1 {v4.4S, v5.4S}, [x1], #32 + ld1 {v6.4S, v7.4S}, [x1], #32 + fmla v16.4S, v4.4S, v0.S[0] + fmla v17.4S, v5.4S, v0.S[0] + fmla v18.4S, v6.4S, v0.S[0] + fmla v19.4S, v7.4S, v0.S[0] + st1 {v16.4S, v17.4S}, [x0], #32 + st1 {v18.4S, v19.4S}, [x0], #32 + b.ne 1b + ret +endfunc + +function ff_vector_fmul_scalar_neon, export=1 + mov w4, #15 + bics w3, w2, w4 + dup v16.4S, v0.S[0] + b.eq 3f + ld1 {v0.4S, v1.4S}, [x1], #32 +1: subs w3, w3, #16 + fmul v0.4S, v0.4S, v16.4S + ld1 {v2.4S, v3.4S}, [x1], #32 + fmul v1.4S, v1.4S, v16.4S + fmul v2.4S, v2.4S, v16.4S + st1 {v0.4S, v1.4S}, [x0], #32 + fmul v3.4S, v3.4S, v16.4S + b.eq 2f + ld1 {v0.4S, v1.4S}, [x1], #32 + st1 {v2.4S, v3.4S}, [x0], #32 + b 1b +2: ands w2, w2, #15 + st1 {v2.4S, v3.4S}, [x0], #32 + b.eq 4f +3: ld1 {v0.4S}, [x1], #16 + fmul v0.4S, v0.4S, v16.4S + st1 {v0.4S}, [x0], #16 + subs w2, w2, #4 + b.gt 3b +4: ret +endfunc + +function ff_vector_dmul_scalar_neon, export=1 + dup v16.2D, v0.D[0] + ld1 {v0.2D, v1.2D}, [x1], #32 +1: subs w2, w2, #8 + fmul v0.2D, v0.2D, v16.2D + ld1 {v2.2D, v3.2D}, [x1], #32 + fmul v1.2D, v1.2D, v16.2D + fmul v2.2D, v2.2D, v16.2D + st1 {v0.2D, v1.2D}, [x0], #32 + fmul v3.2D, v3.2D, v16.2D + ld1 {v0.2D, v1.2D}, [x1], #32 + st1 {v2.2D, v3.2D}, [x0], #32 + b.gt 1b + ret +endfunc + +function ff_vector_fmul_window_neon, export=1 + sxtw x4, w4 // len + sub x2, x2, #8 + sub x5, x4, #2 + add x2, x2, x5, lsl #2 // src1 + 4 * (len - 4) + add x6, x3, x5, lsl #3 // win + 8 * (len - 2) + add x5, x0, x5, lsl #3 // dst + 8 * (len - 2) + mov x7, #-16 + ld1 {v0.4S}, [x1], #16 // s0 + ld1 {v2.4S}, [x3], #16 // wi + ld1 {v1.4S}, [x2], x7 // s1 +1: ld1 {v3.4S}, [x6], x7 // wj + subs x4, x4, #4 + fmul v17.4S, v0.4S, v2.4S // s0 * wi + rev64 v4.4S, v1.4S + rev64 v5.4S, v3.4S + rev64 v17.4S, v17.4S + ext v4.16B, v4.16B, v4.16B, #8 // s1_r + ext v5.16B, v5.16B, v5.16B, #8 // wj_r + ext v17.16B, v17.16B, v17.16B, #8 // (s0 * wi)_rev + fmul v16.4S, v0.4S, v5.4S // s0 * wj_r + fmla v17.4S, v1.4S, v3.4S // (s0 * wi)_rev + s1 * wj + b.eq 2f + ld1 {v0.4S}, [x1], #16 + fmls v16.4S, v4.4S, v2.4S // s0 * wj_r - s1_r * wi + st1 {v17.4S}, [x5], x7 + ld1 {v2.4S}, [x3], #16 + ld1 {v1.4S}, [x2], x7 + st1 {v16.4S}, [x0], #16 + b 1b +2: + fmls v16.4S, v4.4S, v2.4S // s0 * wj_r - s1_r * wi + st1 {v17.4S}, [x5], x7 + st1 {v16.4S}, [x0], #16 + ret +endfunc + +function ff_vector_fmul_add_neon, export=1 + ld1 {v0.4S, v1.4S}, [x1], #32 + ld1 {v2.4S, v3.4S}, [x2], #32 + ld1 {v4.4S, v5.4S}, [x3], #32 +1: subs w4, w4, #8 + fmla v4.4S, v0.4S, v2.4S + fmla v5.4S, v1.4S, v3.4S + b.eq 2f + ld1 {v0.4S, v1.4S}, [x1], #32 + ld1 {v2.4S, v3.4S}, [x2], #32 + st1 {v4.4S, v5.4S}, [x0], #32 + ld1 {v4.4S, v5.4S}, [x3], #32 + b 1b +2: st1 {v4.4S, v5.4S}, [x0], #32 + ret +endfunc + +function ff_vector_fmul_reverse_neon, export=1 + sxtw x3, w3 + add x2, x2, x3, lsl #2 + sub x2, x2, #32 + mov x4, #-32 + ld1 {v2.4S, v3.4S}, [x2], x4 + ld1 {v0.4S, v1.4S}, [x1], #32 +1: subs x3, x3, #8 + rev64 v3.4S, v3.4S + rev64 v2.4S, v2.4S + ext v3.16B, v3.16B, v3.16B, #8 + ext v2.16B, v2.16B, v2.16B, #8 + fmul v16.4S, v0.4S, v3.4S + fmul v17.4S, v1.4S, v2.4S + b.eq 2f + ld1 {v2.4S, v3.4S}, [x2], x4 + ld1 {v0.4S, v1.4S}, [x1], #32 + st1 {v16.4S, v17.4S}, [x0], #32 + b 1b +2: st1 {v16.4S, v17.4S}, [x0], #32 + ret +endfunc + +function ff_butterflies_float_neon, export=1 +1: ld1 {v0.4S}, [x0] + ld1 {v1.4S}, [x1] + subs w2, w2, #4 + fsub v2.4S, v0.4S, v1.4S + fadd v3.4S, v0.4S, v1.4S + st1 {v2.4S}, [x1], #16 + st1 {v3.4S}, [x0], #16 + b.gt 1b + ret +endfunc + +function ff_scalarproduct_float_neon, export=1 + movi v2.4S, #0 +1: ld1 {v0.4S}, [x0], #16 + ld1 {v1.4S}, [x1], #16 + subs w2, w2, #4 + fmla v2.4S, v0.4S, v1.4S + b.gt 1b + faddp v0.4S, v2.4S, v2.4S + faddp s0, v0.2S + ret +endfunc diff --git a/chromium/third_party/ffmpeg/libavutil/aarch64/neontest.h b/chromium/third_party/ffmpeg/libavutil/aarch64/neontest.h new file mode 100644 index 00000000000..b9d49860725 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/aarch64/neontest.h @@ -0,0 +1,65 @@ +/* + * check NEON registers for clobbering + * Copyright (c) 2008 Ramiro Polla <ramiro.polla@gmail.com> + * Copyright (c) 2013 Martin Storsjo + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> + +#include "libavutil/bswap.h" + +#define storeneonregs(mem) \ + __asm__ volatile( \ + "stp d8, d9, [%0]\n\t" \ + "stp d10, d11, [%0, #16]\n\t" \ + "stp d12, d13, [%0, #32]\n\t" \ + "stp d14, d15, [%0, #48]\n\t" \ + :: "r"(mem) : "memory") + +#define testneonclobbers(func, ctx, ...) \ + uint64_t neon[2][8]; \ + int ret; \ + storeneonregs(neon[0]); \ + ret = __real_ ## func(ctx, __VA_ARGS__); \ + storeneonregs(neon[1]); \ + if (memcmp(neon[0], neon[1], sizeof(neon[0]))) { \ + int i; \ + av_log(ctx, AV_LOG_ERROR, \ + "NEON REGS CLOBBERED IN %s!\n", #func); \ + for (i = 0; i < 8; i ++) \ + if (neon[0][i] != neon[1][i]) { \ + av_log(ctx, AV_LOG_ERROR, \ + "d%-2d = %016"PRIx64"\n", \ + 8 + i, av_bswap64(neon[0][i])); \ + av_log(ctx, AV_LOG_ERROR, \ + " -> %016"PRIx64"\n", \ + av_bswap64(neon[1][i])); \ + } \ + abort(); \ + } \ + return ret + +#define wrap(func) \ +int __real_ ## func; \ +int __wrap_ ## func; \ +int __wrap_ ## func diff --git a/chromium/third_party/ffmpeg/libavutil/aes.c b/chromium/third_party/ffmpeg/libavutil/aes.c index a3eb295e244..638fb81e8da 100644 --- a/chromium/third_party/ffmpeg/libavutil/aes.c +++ b/chromium/third_party/ffmpeg/libavutil/aes.c @@ -23,6 +23,7 @@ #include "common.h" #include "aes.h" #include "intreadwrite.h" +#include "timer.h" typedef union { uint64_t u64[2]; diff --git a/chromium/third_party/ffmpeg/libavutil/arm/asm.S b/chromium/third_party/ffmpeg/libavutil/arm/asm.S index 9cdcce9a180..08669f043cf 100644 --- a/chromium/third_party/ffmpeg/libavutil/arm/asm.S +++ b/chromium/third_party/ffmpeg/libavutil/arm/asm.S @@ -53,8 +53,9 @@ .syntax unified T .thumb ELF .eabi_attribute 25, 1 @ Tag_ABI_align_preserved +ELF .section .note.GNU-stack,"",%progbits @ Mark stack as non-executable -.macro function name, export=0 +.macro function name, export=0, align=2 .set .Lpic_idx, 0 .set .Lpic_gp, 0 .macro endfunc @@ -69,14 +70,17 @@ ELF .size \name, . - \name .purgem endfunc .endm .text - .align 2 + .align \align .if \export .global EXTERN_ASM\name +ELF .type EXTERN_ASM\name, %function + .func EXTERN_ASM\name EXTERN_ASM\name: - .endif + .else ELF .type \name, %function .func \name \name: + .endif .endm .macro const name, align=2 @@ -212,6 +216,13 @@ T ldr \rt, [\rn] T add \rn, \rn, \rm .endm +.macro ldrc_pre cc, rt, rn, rm:vararg +A ldr\cc \rt, [\rn, \rm]! +T itt \cc +T add\cc \rn, \rn, \rm +T ldr\cc \rt, [\rn] +.endm + .macro ldrd_reg rt, rt2, rn, rm A ldrd \rt, \rt2, [\rn, \rm] T add \rt, \rn, \rm diff --git a/chromium/third_party/ffmpeg/libavutil/arm/float_dsp_init_arm.c b/chromium/third_party/ffmpeg/libavutil/arm/float_dsp_init_arm.c index 38148b38786..678762862ec 100644 --- a/chromium/third_party/ffmpeg/libavutil/arm/float_dsp_init_arm.c +++ b/chromium/third_party/ffmpeg/libavutil/arm/float_dsp_init_arm.c @@ -1,6 +1,4 @@ /* - * ARM optimized DSP utils - * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or diff --git a/chromium/third_party/ffmpeg/libavutil/arm/intmath.h b/chromium/third_party/ffmpeg/libavutil/arm/intmath.h index fd52648f884..faea5ea4032 100644 --- a/chromium/third_party/ffmpeg/libavutil/arm/intmath.h +++ b/chromium/third_party/ffmpeg/libavutil/arm/intmath.h @@ -62,6 +62,11 @@ static av_always_inline av_const int av_clip_int16_arm(int a) return x; } +/* +TODO(dalecurtis): This causes compilation to fail if the function can't be +inlined because the 2nd operand in usat must be an immediate. So disable since +av_always_inline doesn't seem to really mean always... + #define av_clip_uintp2 av_clip_uintp2_arm static av_always_inline av_const unsigned av_clip_uintp2_arm(int a, int p) { @@ -69,6 +74,7 @@ static av_always_inline av_const unsigned av_clip_uintp2_arm(int a, int p) __asm__ ("usat %0, %2, %1" : "=r"(x) : "r"(a), "i"(p)); return x; } +*/ #define av_sat_add32 av_sat_add32_arm static av_always_inline int av_sat_add32_arm(int a, int b) diff --git a/chromium/third_party/ffmpeg/libavutil/arm/neontest.h b/chromium/third_party/ffmpeg/libavutil/arm/neontest.h new file mode 100644 index 00000000000..f668c00733f --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/arm/neontest.h @@ -0,0 +1,62 @@ +/* + * check NEON registers for clobbering + * Copyright (c) 2008 Ramiro Polla <ramiro.polla@gmail.com> + * Copyright (c) 2013 Martin Storsjo + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include <inttypes.h> +#include <stdint.h> +#include <stdlib.h> +#include <stdarg.h> +#include <string.h> + +#include "libavutil/bswap.h" + +#define storeneonregs(mem) \ + __asm__ volatile( \ + "vstm %0, {d8-d15}\n\t" \ + :: "r"(mem) : "memory") + +#define testneonclobbers(func, ctx, ...) \ + uint64_t neon[2][8]; \ + int ret; \ + storeneonregs(neon[0]); \ + ret = __real_ ## func(ctx, __VA_ARGS__); \ + storeneonregs(neon[1]); \ + if (memcmp(neon[0], neon[1], sizeof(neon[0]))) { \ + int i; \ + av_log(ctx, AV_LOG_ERROR, \ + "NEON REGS CLOBBERED IN %s!\n", #func); \ + for (i = 0; i < 8; i ++) \ + if (neon[0][i] != neon[1][i]) { \ + av_log(ctx, AV_LOG_ERROR, \ + "d%-2d = %016"PRIx64"\n", \ + 8 + i, av_bswap64(neon[0][i])); \ + av_log(ctx, AV_LOG_ERROR, \ + " -> %016"PRIx64"\n", \ + av_bswap64(neon[1][i])); \ + } \ + abort(); \ + } \ + return ret + +#define wrap(func) \ +int __real_ ## func; \ +int __wrap_ ## func; \ +int __wrap_ ## func diff --git a/chromium/third_party/ffmpeg/libavutil/atomic.c b/chromium/third_party/ffmpeg/libavutil/atomic.c index 04182f2330b..1fa63086309 100644 --- a/chromium/third_party/ffmpeg/libavutil/atomic.c +++ b/chromium/third_party/ffmpeg/libavutil/atomic.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" #include "atomic.h" #if !HAVE_ATOMICS_NATIVE @@ -96,13 +97,16 @@ void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval) return *ptr; } -#else +#else /* HAVE_THREADS */ +/* This should never trigger, unless a new threading implementation + * without correct atomics dependencies in configure or a corresponding + * atomics implementation is added. */ #error "Threading is enabled, but there is no implementation of atomic operations available" #endif /* HAVE_PTHREADS */ -#endif /* !HAVE_MEMORYBARRIER && !HAVE_SYNC_VAL_COMPARE_AND_SWAP && !HAVE_MACHINE_RW_BARRIER */ +#endif /* !HAVE_ATOMICS_NATIVE */ #ifdef TEST #include "avassert.h" diff --git a/chromium/third_party/ffmpeg/libavutil/atomic.h b/chromium/third_party/ffmpeg/libavutil/atomic.h index fd7d8fc03e0..15906d24c9c 100644 --- a/chromium/third_party/ffmpeg/libavutil/atomic.h +++ b/chromium/third_party/ffmpeg/libavutil/atomic.h @@ -23,12 +23,16 @@ #include "config.h" +#if HAVE_ATOMICS_NATIVE + #if HAVE_ATOMICS_GCC #include "atomic_gcc.h" #elif HAVE_ATOMICS_WIN32 #include "atomic_win32.h" #elif HAVE_ATOMICS_SUNCC #include "atomic_suncc.h" +#endif + #else /** @@ -70,5 +74,6 @@ int avpriv_atomic_int_add_and_fetch(volatile int *ptr, int inc); */ void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval); -#endif /* HAVE_MEMORYBARRIER */ +#endif /* HAVE_ATOMICS_NATIVE */ + #endif /* AVUTIL_ATOMIC_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/audio_fifo.c b/chromium/third_party/ffmpeg/libavutil/audio_fifo.c index cfbde899235..c3aadfdab70 100644 --- a/chromium/third_party/ffmpeg/libavutil/audio_fifo.c +++ b/chromium/third_party/ffmpeg/libavutil/audio_fifo.c @@ -76,7 +76,7 @@ AVAudioFifo *av_audio_fifo_alloc(enum AVSampleFormat sample_fmt, int channels, af->sample_size = buf_size / nb_samples; af->nb_buffers = av_sample_fmt_is_planar(sample_fmt) ? channels : 1; - af->buf = av_mallocz(af->nb_buffers * sizeof(*af->buf)); + af->buf = av_mallocz_array(af->nb_buffers, sizeof(*af->buf)); if (!af->buf) goto error; diff --git a/chromium/third_party/ffmpeg/libavutil/avstring.c b/chromium/third_party/ffmpeg/libavutil/avstring.c index 20931071b32..e75cdc63120 100644 --- a/chromium/third_party/ffmpeg/libavutil/avstring.c +++ b/chromium/third_party/ffmpeg/libavutil/avstring.c @@ -331,15 +331,15 @@ int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end, while (code & top) { int tmp; if (p >= buf_end) { - ret = AVERROR(EILSEQ); /* incomplete sequence */ - goto end; + (*bufp) ++; + return AVERROR(EILSEQ); /* incomplete sequence */ } /* we assume the byte to be in the form 10xx-xxxx */ tmp = *p++ - 128; /* strip leading 1 */ if (tmp>>6) { - ret = AVERROR(EILSEQ); - goto end; + (*bufp) ++; + return AVERROR(EILSEQ); } code = (code<<6) + tmp; top <<= 5; @@ -362,8 +362,8 @@ int av_utf8_decode(int32_t *codep, const uint8_t **bufp, const uint8_t *buf_end, if (code >= 0xD800 && code <= 0xDFFF && !(flags & AV_UTF8_FLAG_ACCEPT_SURROGATES)) ret = AVERROR(EILSEQ); - if (code == 0xFFFE || code == 0xFFFF && - (!flags & AV_UTF8_FLAG_ACCEPT_NON_CHARACTERS)) + if ((code == 0xFFFE || code == 0xFFFF) && + !(flags & AV_UTF8_FLAG_ACCEPT_NON_CHARACTERS)) ret = AVERROR(EILSEQ); end: diff --git a/chromium/third_party/ffmpeg/libavutil/avstring.h b/chromium/third_party/ffmpeg/libavutil/avstring.h index 882a2b57dc2..de2f71d12b6 100644 --- a/chromium/third_party/ffmpeg/libavutil/avstring.h +++ b/chromium/third_party/ffmpeg/libavutil/avstring.h @@ -132,6 +132,20 @@ size_t av_strlcat(char *dst, const char *src, size_t size); size_t av_strlcatf(char *dst, size_t size, const char *fmt, ...) av_printf_format(3, 4); /** + * Get the count of continuous non zero chars starting from the beginning. + * + * @param len maximum number of characters to check in the string, that + * is the maximum value which is returned by the function + */ +static inline size_t av_strnlen(const char *s, size_t len) +{ + size_t i; + for (i = 0; i < len && s[i]; i++) + ; + return i; +} + +/** * Print arguments following specified format into a large enough auto * allocated buffer. It is similar to GNU asprintf(). * @param fmt printf-compatible format string, specifying how the diff --git a/chromium/third_party/ffmpeg/libavutil/avutil.h b/chromium/third_party/ffmpeg/libavutil/avutil.h index 4e680ed0e01..ba6bb020513 100644 --- a/chromium/third_party/ffmpeg/libavutil/avutil.h +++ b/chromium/third_party/ffmpeg/libavutil/avutil.h @@ -41,7 +41,7 @@ * @li @ref lavu "libavutil" common utility library * @li @ref lswr "libswresample" audio resampling, format conversion and mixing * @li @ref lpp "libpostproc" post processing library - * @li @ref lsws "libswscale" color conversion and scaling library + * @li @ref libsws "libswscale" color conversion and scaling library * * @section ffmpeg_versioning Versioning and compatibility * @@ -145,6 +145,12 @@ * @{ * * @} + * + * @defgroup preproc_misc Preprocessor String Macros + * + * @{ + * + * @} */ @@ -276,10 +282,10 @@ char av_get_picture_type_char(enum AVPictureType pict_type); #include "common.h" #include "error.h" +#include "rational.h" #include "version.h" +#include "macros.h" #include "mathematics.h" -#include "rational.h" -#include "intfloat_readwrite.h" #include "log.h" #include "pixfmt.h" @@ -320,6 +326,11 @@ unsigned av_int_list_length_for_size(unsigned elsize, FILE *av_fopen_utf8(const char *path, const char *mode); /** + * Return the fractional representation of the internal time base. + */ +AVRational av_get_time_base_q(void); + +/** * @} * @} */ diff --git a/chromium/third_party/ffmpeg/libavutil/base64.c b/chromium/third_party/ffmpeg/libavutil/base64.c index 348690d32e7..03ebce8b803 100644 --- a/chromium/third_party/ffmpeg/libavutil/base64.c +++ b/chromium/third_party/ffmpeg/libavutil/base64.c @@ -27,6 +27,7 @@ #include "common.h" #include "base64.h" #include "intreadwrite.h" +#include "timer.h" /* ---------------- private code */ static const uint8_t map2[256] = diff --git a/chromium/third_party/ffmpeg/libavutil/bfin/asm.h b/chromium/third_party/ffmpeg/libavutil/bfin/asm.h new file mode 100644 index 00000000000..703e65d9a8c --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/bfin/asm.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2007 Marc Hoffman <marc.hoffman@analog.com> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_BFIN_ASM_H +#define AVUTIL_BFIN_ASM_H + +#include "config.h" + +#define mL3 .text + +#if defined(__FDPIC__) && CONFIG_SRAM +#define mL1 .l1.text +#define SECTION_L1_DATA_A .section .l1.data.A,"aw",@progbits +#define SECTION_L1_DATA_B .section .l1.data.B,"aw",@progbits +#else +#define mL1 mL3 +#define SECTION_L1_DATA_A +#define SECTION_L1_DATA_B .data +#endif + +#define DEFUN(fname, where, interface) \ + .section where; \ + .global _ff_bfin_ ## fname; \ + .type _ff_bfin_ ## fname, STT_FUNC; \ + .align 8; \ + _ff_bfin_ ## fname + +#define DEFUN_END(fname) \ + .size _ff_bfin_ ## fname, . - _ff_bfin_ ## fname + +#ifdef __FDPIC__ +#define RELOC(reg, got, obj) reg = [got + obj@GOT17M4] +#else +#define RELOC(reg, got, obj) reg.L = obj; reg.H = obj +#endif + +#endif /* AVUTIL_BFIN_ASM_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/bfin/attributes.h b/chromium/third_party/ffmpeg/libavutil/bfin/attributes.h new file mode 100644 index 00000000000..f55699e523b --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/bfin/attributes.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2007 Marc Hoffman <mmh@pleasantst.com> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_BFIN_ATTRIBUTES_H +#define AVUTIL_BFIN_ATTRIBUTES_H + +#include "config.h" + +#if defined(__FDPIC__) && CONFIG_SRAM +#define attribute_l1_text __attribute__((l1_text)) +#define attribute_l1_data_b __attribute__((l1_data_B)) +#else +#define attribute_l1_text +#define attribute_l1_data_b +#endif + +#endif /* AVUTIL_BFIN_ATTRIBUTES_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/bswap.h b/chromium/third_party/ffmpeg/libavutil/bswap.h index 06f654816d8..f38e1dec83d 100644 --- a/chromium/third_party/ffmpeg/libavutil/bswap.h +++ b/chromium/third_party/ffmpeg/libavutil/bswap.h @@ -34,7 +34,9 @@ #include "config.h" -#if ARCH_ARM +#if ARCH_AARCH64 +# include "aarch64/bswap.h" +#elif ARCH_ARM # include "arm/bswap.h" #elif ARCH_AVR32 # include "avr32/bswap.h" diff --git a/chromium/third_party/ffmpeg/libavutil/channel_layout.h b/chromium/third_party/ffmpeg/libavutil/channel_layout.h index ba4f96d2d04..bc6befd8e38 100644 --- a/chromium/third_party/ffmpeg/libavutil/channel_layout.h +++ b/chromium/third_party/ffmpeg/libavutil/channel_layout.h @@ -114,6 +114,10 @@ enum AVMatrixEncoding { AV_MATRIX_ENCODING_NONE, AV_MATRIX_ENCODING_DOLBY, AV_MATRIX_ENCODING_DPLII, + AV_MATRIX_ENCODING_DPLIIX, + AV_MATRIX_ENCODING_DPLIIZ, + AV_MATRIX_ENCODING_DOLBYEX, + AV_MATRIX_ENCODING_DOLBYHEADPHONE, AV_MATRIX_ENCODING_NB }; diff --git a/chromium/third_party/ffmpeg/libavutil/cpu.c b/chromium/third_party/ffmpeg/libavutil/cpu.c index e0806b18560..c4517bab673 100644 --- a/chromium/third_party/ffmpeg/libavutil/cpu.c +++ b/chromium/third_party/ffmpeg/libavutil/cpu.c @@ -56,9 +56,14 @@ int av_get_cpu_flags(void) if (checked) return flags; - if (ARCH_ARM) flags = ff_get_cpu_flags_arm(); - if (ARCH_PPC) flags = ff_get_cpu_flags_ppc(); - if (ARCH_X86) flags = ff_get_cpu_flags_x86(); + if (ARCH_AARCH64) + flags = ff_get_cpu_flags_aarch64(); + if (ARCH_ARM) + flags = ff_get_cpu_flags_arm(); + if (ARCH_PPC) + flags = ff_get_cpu_flags_ppc(); + if (ARCH_X86) + flags = ff_get_cpu_flags_x86(); checked = 1; return flags; @@ -86,8 +91,11 @@ int av_parse_cpu_flags(const char *s) #define CPUFLAG_SSE42 (AV_CPU_FLAG_SSE42 | CPUFLAG_SSE4) #define CPUFLAG_AVX (AV_CPU_FLAG_AVX | CPUFLAG_SSE42) #define CPUFLAG_XOP (AV_CPU_FLAG_XOP | CPUFLAG_AVX) +#define CPUFLAG_FMA3 (AV_CPU_FLAG_FMA3 | CPUFLAG_AVX) #define CPUFLAG_FMA4 (AV_CPU_FLAG_FMA4 | CPUFLAG_AVX) #define CPUFLAG_AVX2 (AV_CPU_FLAG_AVX2 | CPUFLAG_AVX) +#define CPUFLAG_BMI1 (AV_CPU_FLAG_BMI1) +#define CPUFLAG_BMI2 (AV_CPU_FLAG_BMI2 | CPUFLAG_BMI1) static const AVOption cpuflags_opts[] = { { "flags" , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" }, #if ARCH_PPC @@ -106,8 +114,11 @@ int av_parse_cpu_flags(const char *s) { "sse4.2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE42 }, .unit = "flags" }, { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX }, .unit = "flags" }, { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_XOP }, .unit = "flags" }, + { "fma3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA3 }, .unit = "flags" }, { "fma4" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA4 }, .unit = "flags" }, { "avx2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX2 }, .unit = "flags" }, + { "bmi1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_BMI1 }, .unit = "flags" }, + { "bmi2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_BMI2 }, .unit = "flags" }, { "3dnow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOW }, .unit = "flags" }, { "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOWEXT }, .unit = "flags" }, { "cmov", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV }, .unit = "flags" }, @@ -118,6 +129,10 @@ int av_parse_cpu_flags(const char *s) { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" }, { "vfpv3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFPV3 }, .unit = "flags" }, { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" }, +#elif ARCH_AARCH64 + { "armv8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV8 }, .unit = "flags" }, + { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" }, + { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" }, #endif { NULL }, }; @@ -158,7 +173,11 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) { "sse4.2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_SSE42 }, .unit = "flags" }, { "avx" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVX }, .unit = "flags" }, { "xop" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_XOP }, .unit = "flags" }, + { "fma3" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_FMA3 }, .unit = "flags" }, { "fma4" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_FMA4 }, .unit = "flags" }, + { "avx2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_AVX2 }, .unit = "flags" }, + { "bmi1" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_BMI1 }, .unit = "flags" }, + { "bmi2" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_BMI2 }, .unit = "flags" }, { "3dnow" , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_3DNOW }, .unit = "flags" }, { "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_3DNOWEXT }, .unit = "flags" }, { "cmov", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV }, .unit = "flags" }, @@ -244,7 +263,11 @@ static const struct { int flag; const char *name; } cpu_flag_tab[] = { -#if ARCH_ARM +#if ARCH_AARCH64 + { AV_CPU_FLAG_ARMV8, "armv8" }, + { AV_CPU_FLAG_NEON, "neon" }, + { AV_CPU_FLAG_VFP, "vfp" }, +#elif ARCH_ARM { AV_CPU_FLAG_ARMV5TE, "armv5te" }, { AV_CPU_FLAG_ARMV6, "armv6" }, { AV_CPU_FLAG_ARMV6T2, "armv6t2" }, @@ -267,11 +290,14 @@ static const struct { { AV_CPU_FLAG_SSE42, "sse4.2" }, { AV_CPU_FLAG_AVX, "avx" }, { AV_CPU_FLAG_XOP, "xop" }, + { AV_CPU_FLAG_FMA3, "fma3" }, { AV_CPU_FLAG_FMA4, "fma4" }, { AV_CPU_FLAG_3DNOW, "3dnow" }, { AV_CPU_FLAG_3DNOWEXT, "3dnowext" }, { AV_CPU_FLAG_CMOV, "cmov" }, { AV_CPU_FLAG_AVX2, "avx2" }, + { AV_CPU_FLAG_BMI1, "bmi1" }, + { AV_CPU_FLAG_BMI2, "bmi2" }, #endif { 0 } }; diff --git a/chromium/third_party/ffmpeg/libavutil/cpu.h b/chromium/third_party/ffmpeg/libavutil/cpu.h index 55c3ec9a06f..8ff14d3adaa 100644 --- a/chromium/third_party/ffmpeg/libavutil/cpu.h +++ b/chromium/third_party/ffmpeg/libavutil/cpu.h @@ -51,6 +51,9 @@ // #define AV_CPU_FLAG_CMOV 0x1000 ///< supports cmov instruction // #endif #define AV_CPU_FLAG_AVX2 0x8000 ///< AVX2 functions: requires OS support even if YMM registers aren't used +#define AV_CPU_FLAG_FMA3 0x10000 ///< Haswell FMA3 functions +#define AV_CPU_FLAG_BMI1 0x20000 ///< Bit Manipulation Instruction Set 1 +#define AV_CPU_FLAG_BMI2 0x40000 ///< Bit Manipulation Instruction Set 2 #define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard @@ -60,6 +63,7 @@ #define AV_CPU_FLAG_VFP (1 << 3) #define AV_CPU_FLAG_VFPV3 (1 << 4) #define AV_CPU_FLAG_NEON (1 << 5) +#define AV_CPU_FLAG_ARMV8 (1 << 6) /** * Return the flags which specify extensions supported by the CPU. diff --git a/chromium/third_party/ffmpeg/libavutil/cpu_internal.h b/chromium/third_party/ffmpeg/libavutil/cpu_internal.h index 8597a32eb77..3c6ce6d079c 100644 --- a/chromium/third_party/ffmpeg/libavutil/cpu_internal.h +++ b/chromium/third_party/ffmpeg/libavutil/cpu_internal.h @@ -26,6 +26,7 @@ #define CPUEXT(flags, cpuext) CPUEXT_SUFFIX(flags, , cpuext) +int ff_get_cpu_flags_aarch64(void); int ff_get_cpu_flags_arm(void); int ff_get_cpu_flags_ppc(void); int ff_get_cpu_flags_x86(void); diff --git a/chromium/third_party/ffmpeg/libavutil/crc.c b/chromium/third_party/ffmpeg/libavutil/crc.c index b429fe1e354..d8b1c99d1cb 100644 --- a/chromium/third_party/ffmpeg/libavutil/crc.c +++ b/chromium/third_party/ffmpeg/libavutil/crc.c @@ -248,6 +248,41 @@ static const AVCRC av_crc_table[AV_CRC_MAX][257] = { 0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D, 0x00000001 }, + [AV_CRC_16_ANSI_LE] = { + 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241, + 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440, + 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40, + 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841, + 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40, + 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41, + 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641, + 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040, + 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240, + 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441, + 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41, + 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840, + 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41, + 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40, + 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640, + 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041, + 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240, + 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441, + 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41, + 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840, + 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41, + 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40, + 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640, + 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041, + 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241, + 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440, + 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40, + 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841, + 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40, + 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41, + 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641, + 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040, + 0x0001 + }, }; #else #if CONFIG_SMALL @@ -266,6 +301,7 @@ static struct { [AV_CRC_24_IEEE] = { 0, 24, 0x864CFB }, [AV_CRC_32_IEEE] = { 0, 32, 0x04C11DB7 }, [AV_CRC_32_IEEE_LE] = { 1, 32, 0xEDB88320 }, + [AV_CRC_16_ANSI_LE] = { 1, 16, 0xA001 }, }; static AVCRC av_crc_table[AV_CRC_MAX][CRC_TABLE_SIZE]; #endif @@ -347,9 +383,10 @@ int main(void) { uint8_t buf[1999]; int i; - int p[5][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 }, + int p[6][3] = { { AV_CRC_32_IEEE_LE, 0xEDB88320, 0x3D5CDD04 }, { AV_CRC_32_IEEE , 0x04C11DB7, 0xC0F5BAE0 }, { AV_CRC_24_IEEE , 0x864CFB , 0xB704CE }, + { AV_CRC_16_ANSI_LE, 0xA001 , 0xBFD8 }, { AV_CRC_16_ANSI , 0x8005 , 0x1FBB }, { AV_CRC_8_ATM , 0x07 , 0xE3 } }; @@ -358,7 +395,7 @@ int main(void) for (i = 0; i < sizeof(buf); i++) buf[i] = i + i * i; - for (i = 0; i < 5; i++) { + for (i = 0; i < 6; i++) { ctx = av_crc_get_table(p[i][0]); printf("crc %08X = %X\n", p[i][1], av_crc(ctx, 0, buf, sizeof(buf))); } diff --git a/chromium/third_party/ffmpeg/libavutil/crc.h b/chromium/third_party/ffmpeg/libavutil/crc.h index f4219ca5bb0..e86bf1deba1 100644 --- a/chromium/third_party/ffmpeg/libavutil/crc.h +++ b/chromium/third_party/ffmpeg/libavutil/crc.h @@ -39,6 +39,7 @@ typedef enum { AV_CRC_16_CCITT, AV_CRC_32_IEEE, AV_CRC_32_IEEE_LE, /*< reversed bitorder version of AV_CRC_32_IEEE */ + AV_CRC_16_ANSI_LE, /*< reversed bitorder version of AV_CRC_16_ANSI */ AV_CRC_24_IEEE = 12, AV_CRC_MAX, /*< Not part of public API! Do not use outside libavutil. */ }AVCRCId; diff --git a/chromium/third_party/ffmpeg/libavutil/dict.c b/chromium/third_party/ffmpeg/libavutil/dict.c index 3a0e84cd407..f7aa7094ad0 100644 --- a/chromium/third_party/ffmpeg/libavutil/dict.c +++ b/chromium/third_party/ffmpeg/libavutil/dict.c @@ -35,40 +35,47 @@ int av_dict_count(const AVDictionary *m) return m ? m->count : 0; } -AVDictionaryEntry * -av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags) +AVDictionaryEntry *av_dict_get(FF_CONST_AVUTIL53 AVDictionary *m, const char *key, + const AVDictionaryEntry *prev, int flags) { unsigned int i, j; - if(!m) + if (!m) return NULL; - if(prev) i= prev - m->elems + 1; - else i= 0; + if (prev) + i = prev - m->elems + 1; + else + i = 0; - for(; i<m->count; i++){ - const char *s= m->elems[i].key; - if(flags & AV_DICT_MATCH_CASE) for(j=0; s[j] == key[j] && key[j]; j++); - else for(j=0; av_toupper(s[j]) == av_toupper(key[j]) && key[j]; j++); - if(key[j]) + for (; i < m->count; i++) { + const char *s = m->elems[i].key; + if (flags & AV_DICT_MATCH_CASE) + for (j = 0; s[j] == key[j] && key[j]; j++) + ; + else + for (j = 0; av_toupper(s[j]) == av_toupper(key[j]) && key[j]; j++) + ; + if (key[j]) continue; - if(s[j] && !(flags & AV_DICT_IGNORE_SUFFIX)) + if (s[j] && !(flags & AV_DICT_IGNORE_SUFFIX)) continue; return &m->elems[i]; } return NULL; } -int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags) +int av_dict_set(AVDictionary **pm, const char *key, const char *value, + int flags) { - AVDictionary *m = *pm; + AVDictionary *m = *pm; AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags); char *oldval = NULL; - if(!m) + if (!m) m = *pm = av_mallocz(sizeof(*m)); - if(tag) { + if (tag) { if (flags & AV_DICT_DONT_OVERWRITE) return 0; if (flags & AV_DICT_APPEND) @@ -78,16 +85,17 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags av_free(tag->key); *tag = m->elems[--m->count]; } else { - AVDictionaryEntry *tmp = av_realloc(m->elems, (m->count+1) * sizeof(*m->elems)); - if(tmp) { + AVDictionaryEntry *tmp = av_realloc(m->elems, + (m->count + 1) * sizeof(*m->elems)); + if (tmp) m->elems = tmp; - } else + else return AVERROR(ENOMEM); } if (value) { - if (flags & AV_DICT_DONT_STRDUP_KEY) { + if (flags & AV_DICT_DONT_STRDUP_KEY) m->elems[m->count].key = (char*)(intptr_t)key; - } else + else m->elems[m->count].key = av_strdup(key); if (flags & AV_DICT_DONT_STRDUP_VAL) { m->elems[m->count].value = (char*)(intptr_t)value; @@ -164,7 +172,7 @@ void av_dict_free(AVDictionary **pm) AVDictionary *m = *pm; if (m) { - while(m->count--) { + while (m->count--) { av_free(m->elems[m->count].key); av_free(m->elems[m->count].value); } @@ -173,7 +181,7 @@ void av_dict_free(AVDictionary **pm) av_freep(pm); } -void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags) +void av_dict_copy(AVDictionary **dst, FF_CONST_AVUTIL53 AVDictionary *src, int flags) { AVDictionaryEntry *t = NULL; diff --git a/chromium/third_party/ffmpeg/libavutil/dict.h b/chromium/third_party/ffmpeg/libavutil/dict.h index 1dfc5a6443a..cf77cf9a323 100644 --- a/chromium/third_party/ffmpeg/libavutil/dict.h +++ b/chromium/third_party/ffmpeg/libavutil/dict.h @@ -31,6 +31,8 @@ #ifndef AVUTIL_DICT_H #define AVUTIL_DICT_H +#include "version.h" + /** * @addtogroup lavu_dict AVDictionary * @ingroup lavu_data @@ -46,21 +48,21 @@ * entries and finally av_dict_free() to free the dictionary * and all its contents. * - * @code - * AVDictionary *d = NULL; // "create" an empty dictionary - * av_dict_set(&d, "foo", "bar", 0); // add an entry - * - * char *k = av_strdup("key"); // if your strings are already allocated, - * char *v = av_strdup("value"); // you can avoid copying them like this - * av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); - * - * AVDictionaryEntry *t = NULL; - * while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { - * <....> // iterate over all entries in d - * } - * - * av_dict_free(&d); - * @endcode + @code + AVDictionary *d = NULL; // "create" an empty dictionary + AVDictionaryEntry *t = NULL; + + av_dict_set(&d, "foo", "bar", 0); // add an entry + + char *k = av_strdup("key"); // if your strings are already allocated, + char *v = av_strdup("value"); // you can avoid copying them like this + av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); + + while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { + <....> // iterate over all entries in d + } + av_dict_free(&d); + @endcode * */ @@ -85,17 +87,20 @@ typedef struct AVDictionary AVDictionary; /** * Get a dictionary entry with matching key. * + * The returned entry key or value must not be changed, or it will + * cause undefined behavior. + * * To iterate through all the dictionary entries, you can set the matching key * to the null string "" and set the AV_DICT_IGNORE_SUFFIX flag. * * @param prev Set to the previous matching element to find the next. * If set to NULL the first matching element is returned. * @param key matching key - * @param flags Allows case as well as suffix-insensitive comparisons. - * @return Found entry or NULL, changing key or value leads to undefined behavior. + * @param flags a collection of AV_DICT_* flags controlling how the entry is retrieved + * @return found entry or NULL in case no matching entry was found in the dictionary */ AVDictionaryEntry * -av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); +av_dict_get(FF_CONST_AVUTIL53 AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags); /** * Get number of entries in dictionary. @@ -145,7 +150,7 @@ int av_dict_parse_string(AVDictionary **pm, const char *str, * @param flags flags to use when setting entries in *dst * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag */ -void av_dict_copy(AVDictionary **dst, AVDictionary *src, int flags); +void av_dict_copy(AVDictionary **dst, FF_CONST_AVUTIL53 AVDictionary *src, int flags); /** * Free all the memory allocated for an AVDictionary struct diff --git a/chromium/third_party/ffmpeg/libavutil/downmix_info.c b/chromium/third_party/ffmpeg/libavutil/downmix_info.c new file mode 100644 index 00000000000..c634c6a79f0 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/downmix_info.c @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "downmix_info.h" +#include "frame.h" + +AVDownmixInfo *av_downmix_info_update_side_data(AVFrame *frame) +{ + AVFrameSideData *side_data; + + side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_DOWNMIX_INFO); + + if (!side_data) + side_data = av_frame_new_side_data(frame, AV_FRAME_DATA_DOWNMIX_INFO, + sizeof(AVDownmixInfo)); + + if (!side_data) + return NULL; + + return (AVDownmixInfo*)side_data->data; +} diff --git a/chromium/third_party/ffmpeg/libavutil/downmix_info.h b/chromium/third_party/ffmpeg/libavutil/downmix_info.h new file mode 100644 index 00000000000..c369891c02b --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/downmix_info.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2014 Tim Walker <tdskywalker@gmail.com> + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_DOWNMIX_INFO_H +#define AVUTIL_DOWNMIX_INFO_H + +#include "frame.h" + +/** + * @file + * audio downmix medatata + */ + +/** + * @addtogroup lavu_audio + * @{ + */ + +/** + * @defgroup downmix_info Audio downmix metadata + * @{ + */ + +/** + * Possible downmix types. + */ +enum AVDownmixType { + AV_DOWNMIX_TYPE_UNKNOWN, /**< Not indicated. */ + AV_DOWNMIX_TYPE_LORO, /**< Lo/Ro 2-channel downmix (Stereo). */ + AV_DOWNMIX_TYPE_LTRT, /**< Lt/Rt 2-channel downmix, Dolby Surround compatible. */ + AV_DOWNMIX_TYPE_DPLII, /**< Lt/Rt 2-channel downmix, Dolby Pro Logic II compatible. */ + AV_DOWNMIX_TYPE_NB /**< Number of downmix types. Not part of ABI. */ +}; + +/** + * This structure describes optional metadata relevant to a downmix procedure. + * + * All fields are set by the decoder to the value indicated in the audio + * bitstream (if present), or to a "sane" default otherwise. + */ +typedef struct AVDownmixInfo { + /** + * Type of downmix preferred by the mastering engineer. + */ + enum AVDownmixType preferred_downmix_type; + + /** + * Absolute scale factor representing the nominal level of the center + * channel during a regular downmix. + */ + double center_mix_level; + + /** + * Absolute scale factor representing the nominal level of the center + * channel during an Lt/Rt compatible downmix. + */ + double center_mix_level_ltrt; + + /** + * Absolute scale factor representing the nominal level of the surround + * channels during a regular downmix. + */ + double surround_mix_level; + + /** + * Absolute scale factor representing the nominal level of the surround + * channels during an Lt/Rt compatible downmix. + */ + double surround_mix_level_ltrt; + + /** + * Absolute scale factor representing the level at which the LFE data is + * mixed into L/R channels during downmixing. + */ + double lfe_mix_level; +} AVDownmixInfo; + +/** + * Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing. + * + * The side data is created and added to the frame if it's absent. + * + * @param frame the frame for which the side data is to be obtained. + * + * @return the AVDownmixInfo structure to be edited by the caller. + */ +AVDownmixInfo *av_downmix_info_update_side_data(AVFrame *frame); + +/** + * @} + */ + +/** + * @} + */ + +#endif /* AVUTIL_DOWNMIX_INFO_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/dynarray.h b/chromium/third_party/ffmpeg/libavutil/dynarray.h new file mode 100644 index 00000000000..00b19bc2a77 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/dynarray.h @@ -0,0 +1,70 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_DYNARRAY_H +#define AVUTIL_DYNARRAY_H + +#include "log.h" +#include "mem.h" + +/** + * Add an element of to a dynamic array. + * + * The array is reallocated when its number of elements reaches powers of 2. + * Therefore, the amortized cost of adding an element is constant. + * + * In case of success, the pointer to the array is updated in order to + * point to the new grown array, and the size is incremented. + * + * @param av_size_max maximum size of the array, usually the MAX macro of + * the type of the size + * @param av_elt_size size of the elements in the array, in bytes + * @param av_array pointer to the array, must be a lvalue + * @param av_size size of the array, must be an interger lvalue + * @param av_success statement to execute on success; at this point, the + * size variable is not yet incremented + * @param av_failure statement to execute on failure; if this happens, the + * array and size are not changed; the statement can end + * with a return or a goto + */ +#define AV_DYNARRAY_ADD(av_size_max, av_elt_size, av_array, av_size, \ + av_success, av_failure) \ + do { \ + size_t av_size_new = (av_size); \ + if (!((av_size) & ((av_size) - 1))) { \ + av_size_new = (av_size) ? (av_size) << 1 : 1; \ + if (av_size_new > (av_size_max) / (av_elt_size)) { \ + av_size_new = 0; \ + } else { \ + void *av_array_new = \ + av_realloc((av_array), av_size_new * (av_elt_size)); \ + if (!av_array_new) \ + av_size_new = 0; \ + else \ + (av_array) = av_array_new; \ + } \ + } \ + if (av_size_new) { \ + { av_success } \ + (av_size)++; \ + } else { \ + av_failure \ + } \ + } while (0) + +#endif /* AVUTIL_DYNARRAY_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/eval.c b/chromium/third_party/ffmpeg/libavutil/eval.c index 635e538af55..4a313bfad4d 100644 --- a/chromium/third_party/ffmpeg/libavutil/eval.c +++ b/chromium/third_party/ffmpeg/libavutil/eval.c @@ -35,6 +35,7 @@ #include "mathematics.h" #include "time.h" #include "avstring.h" +#include "timer.h" typedef struct Parser { const AVClass *class; diff --git a/chromium/third_party/ffmpeg/libavutil/fifo.c b/chromium/third_party/ffmpeg/libavutil/fifo.c index ca25bc52399..09ffa4fd26e 100644 --- a/chromium/third_party/ffmpeg/libavutil/fifo.c +++ b/chromium/third_party/ffmpeg/libavutil/fifo.c @@ -45,18 +45,26 @@ void av_fifo_free(AVFifoBuffer *f) } } +void av_fifo_freep(AVFifoBuffer **f) +{ + if (f) { + av_fifo_free(*f); + *f = NULL; + } +} + void av_fifo_reset(AVFifoBuffer *f) { f->wptr = f->rptr = f->buffer; f->wndx = f->rndx = 0; } -int av_fifo_size(AVFifoBuffer *f) +int av_fifo_size(FF_CONST_AVUTIL53 AVFifoBuffer *f) { return (uint32_t)(f->wndx - f->rndx); } -int av_fifo_space(AVFifoBuffer *f) +int av_fifo_space(FF_CONST_AVUTIL53 AVFifoBuffer *f) { return f->end - f->buffer - av_fifo_size(f); } diff --git a/chromium/third_party/ffmpeg/libavutil/fifo.h b/chromium/third_party/ffmpeg/libavutil/fifo.h index 849b9a6b813..f0b11094d0c 100644 --- a/chromium/third_party/ffmpeg/libavutil/fifo.h +++ b/chromium/third_party/ffmpeg/libavutil/fifo.h @@ -48,6 +48,12 @@ AVFifoBuffer *av_fifo_alloc(unsigned int size); void av_fifo_free(AVFifoBuffer *f); /** + * Free an AVFifoBuffer and reset pointer to NULL. + * @param f AVFifoBuffer to free + */ +void av_fifo_freep(AVFifoBuffer **f); + +/** * Reset the AVFifoBuffer to the state right after av_fifo_alloc, in particular it is emptied. * @param f AVFifoBuffer to reset */ @@ -59,7 +65,7 @@ void av_fifo_reset(AVFifoBuffer *f); * @param f AVFifoBuffer to read from * @return size */ -int av_fifo_size(AVFifoBuffer *f); +int av_fifo_size(FF_CONST_AVUTIL53 AVFifoBuffer *f); /** * Return the amount of space in bytes in the AVFifoBuffer, that is the @@ -67,7 +73,7 @@ int av_fifo_size(AVFifoBuffer *f); * @param f AVFifoBuffer to write into * @return size */ -int av_fifo_space(AVFifoBuffer *f); +int av_fifo_space(FF_CONST_AVUTIL53 AVFifoBuffer *f); /** * Feed data from an AVFifoBuffer to a user-supplied callback. diff --git a/chromium/third_party/ffmpeg/libavutil/file_open.c b/chromium/third_party/ffmpeg/libavutil/file_open.c index bcdd26ae355..f3164ebe684 100644 --- a/chromium/third_party/ffmpeg/libavutil/file_open.c +++ b/chromium/third_party/ffmpeg/libavutil/file_open.c @@ -48,7 +48,7 @@ static int win32_open(const char *filename_utf8, int oflag, int pmode) num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename_utf8, -1, NULL, 0); if (num_chars <= 0) goto fallback; - filename_w = av_mallocz(sizeof(wchar_t) * num_chars); + filename_w = av_mallocz_array(num_chars, sizeof(wchar_t)); if (!filename_w) { errno = ENOMEM; return -1; diff --git a/chromium/third_party/ffmpeg/libavutil/fixed_dsp.c b/chromium/third_party/ffmpeg/libavutil/fixed_dsp.c new file mode 100644 index 00000000000..b99fea519e1 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/fixed_dsp.c @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2012 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Author: Nedeljko Babic (nbabic@mips.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "fixed_dsp.h" + +static void vector_fmul_window_fixed_scaled_c(int16_t *dst, const int32_t *src0, + const int32_t *src1, const int32_t *win, + int len, uint8_t bits) +{ + int32_t s0, s1, wi, wj, i,j, round; + + dst += len; + win += len; + src0+= len; + round = bits? 1 << (bits-1) : 0; + + for (i=-len, j=len-1; i<0; i++, j--) { + s0 = src0[i]; + s1 = src1[j]; + wi = win[i]; + wj = win[j]; + dst[i] = av_clip_int16_c(((((int64_t)s0*wj - (int64_t)s1*wi + 0x40000000) >> 31) + round) >> bits); + dst[j] = av_clip_int16_c(((((int64_t)s0*wi + (int64_t)s1*wj + 0x40000000) >> 31) + round) >> bits); + } +} + +static void vector_fmul_window_fixed_c(int32_t *dst, const int32_t *src0, + const int32_t *src1, const int32_t *win, + int len) +{ + int32_t s0, s1, wi, wj, i, j; + + dst += len; + win += len; + src0+= len; + + for (i=-len, j=len-1; i<0; i++, j--) { + s0 = src0[i]; + s1 = src1[j]; + wi = win[i]; + wj = win[j]; + dst[i] = ((int64_t)s0*wj - (int64_t)s1*wi + 0x40000000) >> 31; + dst[j] = ((int64_t)s0*wi + (int64_t)s1*wj + 0x40000000) >> 31; + } +} + +AVFixedDSPContext * avpriv_alloc_fixed_dsp(int bit_exact) +{ + AVFixedDSPContext * fdsp = av_malloc(sizeof(AVFixedDSPContext)); + fdsp->vector_fmul_window_scaled = vector_fmul_window_fixed_scaled_c; + fdsp->vector_fmul_window = vector_fmul_window_fixed_c; + + return fdsp; +} diff --git a/chromium/third_party/ffmpeg/libavutil/fixed_dsp.h b/chromium/third_party/ffmpeg/libavutil/fixed_dsp.h new file mode 100644 index 00000000000..ff6f36599a8 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/fixed_dsp.h @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2012 + * MIPS Technologies, Inc., California. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. Neither the name of the MIPS Technologies, Inc., nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE MIPS TECHNOLOGIES, INC. ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE MIPS TECHNOLOGIES, INC. BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Author: Nedeljko Babic (nbabic@mips.com) + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_FIXED_DSP_H +#define AVUTIL_FIXED_DSP_H + +#include <stdint.h> +#include "attributes.h" +#include "common.h" +#include "libavcodec/mathops.h" + +typedef struct AVFixedDSPContext { + /** + * Overlap/add with window function. + * Used primarily by MDCT-based audio codecs. + * Source and destination vectors must overlap exactly or not at all. + * + * @param dst result vector + * constraints: 16-byte aligned + * @param src0 first source vector + * constraints: 16-byte aligned + * @param src1 second source vector + * constraints: 16-byte aligned + * @param win half-window vector + * constraints: 16-byte aligned + * @param len length of vector + * constraints: multiple of 4 + * @param bits scaling parameter + * + */ + void (*vector_fmul_window_scaled)(int16_t *dst, const int32_t *src0, const int32_t *src1, const int32_t *win, int len, uint8_t bits); + + /** + * Overlap/add with window function. + * Used primarily by MDCT-based audio codecs. + * Source and destination vectors must overlap exactly or not at all. + * + * @param dst result vector + * constraints: 32-byte aligned + * @param src0 first source vector + * constraints: 16-byte aligned + * @param src1 second source vector + * constraints: 16-byte aligned + * @param win half-window vector + * constraints: 16-byte aligned + * @param len length of vector + * constraints: multiple of 4 + */ + void (*vector_fmul_window)(int32_t *dst, const int32_t *src0, const int32_t *src1, const int32_t *win, int len); + +} AVFixedDSPContext; + +/** + * Allocate and initialize a fixed DSP context. + * note: should be freed with a av_free call when no longer needed. + * + * @param strict setting to non-zero avoids using functions which may not be IEEE-754 compliant + */ +AVFixedDSPContext * avpriv_alloc_fixed_dsp(int strict); + +/** + * Calculate the square root + * + * @param x input fixed point number + * + * @param bits format of fixed point number (32 - bits).bits + * + * note: input is normalized to (0, 1) fixed point value + */ + +static av_always_inline int fixed_sqrt(int x, int bits) +{ + int retval, bit_mask, guess, square, i; + int64_t accu; + int shift1 = 30 - bits; + int shift2 = bits - 15; + + if (shift1 > 0) retval = ff_sqrt(x << shift1); + else retval = ff_sqrt(x >> -shift1); + + if (shift2 > 0) { + retval = retval << shift2; + bit_mask = (1 << (shift2 - 1)); + + for (i=0; i<shift2; i++){ + guess = retval + bit_mask; + accu = (int64_t)guess * guess; + square = (int)((accu + bit_mask) >> bits); + if (x >= square) + retval += bit_mask; + bit_mask >>= 1; + } + + } + else retval >>= (-shift2); + + return retval; +} + +#endif /* AVUTIL_FIXED_DSP_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/float_dsp.c b/chromium/third_party/ffmpeg/libavutil/float_dsp.c index efff47f89aa..8ac74800eef 100644 --- a/chromium/third_party/ffmpeg/libavutil/float_dsp.c +++ b/chromium/third_party/ffmpeg/libavutil/float_dsp.c @@ -127,13 +127,299 @@ av_cold void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int bit_exact) fdsp->butterflies_float = butterflies_float_c; fdsp->scalarproduct_float = avpriv_scalarproduct_float_c; -#if ARCH_ARM - ff_float_dsp_init_arm(fdsp); -#elif ARCH_PPC - ff_float_dsp_init_ppc(fdsp, bit_exact); -#elif ARCH_X86 - ff_float_dsp_init_x86(fdsp); -#elif ARCH_MIPS - ff_float_dsp_init_mips(fdsp); -#endif + if (ARCH_AARCH64) + ff_float_dsp_init_aarch64(fdsp); + if (ARCH_ARM) + ff_float_dsp_init_arm(fdsp); + if (ARCH_PPC) + ff_float_dsp_init_ppc(fdsp, bit_exact); + if (ARCH_X86) + ff_float_dsp_init_x86(fdsp); + if (ARCH_MIPS) + ff_float_dsp_init_mips(fdsp); } + +#ifdef TEST + +#include <float.h> +#include <math.h> +#include <stdint.h> +#include <stdlib.h> +#include <string.h> + +#include "common.h" +#include "cpu.h" +#include "internal.h" +#include "lfg.h" +#include "log.h" +#include "mem.h" +#include "random_seed.h" + +#define LEN 240 + +static void fill_float_array(AVLFG *lfg, float *a, int len) +{ + int i; + double bmg[2], stddev = 10.0, mean = 0.0; + + for (i = 0; i < len; i += 2) { + av_bmg_get(lfg, bmg); + a[i] = bmg[0] * stddev + mean; + a[i + 1] = bmg[1] * stddev + mean; + } +} +static int compare_floats(const float *a, const float *b, int len, + float max_diff) +{ + int i; + for (i = 0; i < len; i++) { + if (fabsf(a[i] - b[i]) > max_diff) { + av_log(NULL, AV_LOG_ERROR, "%d: %- .12f - %- .12f = % .12g\n", + i, a[i], b[i], a[i] - b[i]); + return -1; + } + } + return 0; +} + +static void fill_double_array(AVLFG *lfg, double *a, int len) +{ + int i; + double bmg[2], stddev = 10.0, mean = 0.0; + + for (i = 0; i < len; i += 2) { + av_bmg_get(lfg, bmg); + a[i] = bmg[0] * stddev + mean; + a[i + 1] = bmg[1] * stddev + mean; + } +} + +static int compare_doubles(const double *a, const double *b, int len, + double max_diff) +{ + int i; + + for (i = 0; i < len; i++) { + if (fabs(a[i] - b[i]) > max_diff) { + av_log(NULL, AV_LOG_ERROR, "%d: %- .12f - %- .12f = % .12g\n", + i, a[i], b[i], a[i] - b[i]); + return -1; + } + } + return 0; +} + +static int test_vector_fmul(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, + const float *v1, const float *v2) +{ + LOCAL_ALIGNED(32, float, cdst, [LEN]); + LOCAL_ALIGNED(32, float, odst, [LEN]); + int ret; + + cdsp->vector_fmul(cdst, v1, v2, LEN); + fdsp->vector_fmul(odst, v1, v2, LEN); + + if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON)) + av_log(NULL, AV_LOG_ERROR, "vector_fmul failed\n"); + + return ret; +} + +#define ARBITRARY_FMAC_SCALAR_CONST 0.005 +static int test_vector_fmac_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, + const float *v1, const float *src0, float scale) +{ + LOCAL_ALIGNED(32, float, cdst, [LEN]); + LOCAL_ALIGNED(32, float, odst, [LEN]); + int ret; + + memcpy(cdst, v1, LEN * sizeof(*v1)); + memcpy(odst, v1, LEN * sizeof(*v1)); + + cdsp->vector_fmac_scalar(cdst, src0, scale, LEN); + fdsp->vector_fmac_scalar(odst, src0, scale, LEN); + + if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMAC_SCALAR_CONST)) + av_log(NULL, AV_LOG_ERROR, "vector_fmac_scalar failed\n"); + + return ret; +} + +static int test_vector_fmul_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, + const float *v1, float scale) +{ + LOCAL_ALIGNED(32, float, cdst, [LEN]); + LOCAL_ALIGNED(32, float, odst, [LEN]); + int ret; + + cdsp->vector_fmul_scalar(cdst, v1, scale, LEN); + fdsp->vector_fmul_scalar(odst, v1, scale, LEN); + + if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON)) + av_log(NULL, AV_LOG_ERROR, "vector_fmul_scalar failed\n"); + + return ret; +} + +static int test_vector_dmul_scalar(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, + const double *v1, double scale) +{ + LOCAL_ALIGNED(32, double, cdst, [LEN]); + LOCAL_ALIGNED(32, double, odst, [LEN]); + int ret; + + cdsp->vector_dmul_scalar(cdst, v1, scale, LEN); + fdsp->vector_dmul_scalar(odst, v1, scale, LEN); + + if (ret = compare_doubles(cdst, odst, LEN, DBL_EPSILON)) + av_log(NULL, AV_LOG_ERROR, "vector_dmul_scalar failed\n"); + + return ret; +} + +#define ARBITRARY_FMUL_WINDOW_CONST 0.008 +static int test_vector_fmul_window(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, + const float *v1, const float *v2, const float *v3) +{ + LOCAL_ALIGNED(32, float, cdst, [LEN]); + LOCAL_ALIGNED(32, float, odst, [LEN]); + int ret; + + cdsp->vector_fmul_window(cdst, v1, v2, v3, LEN / 2); + fdsp->vector_fmul_window(odst, v1, v2, v3, LEN / 2); + + if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_WINDOW_CONST)) + av_log(NULL, AV_LOG_ERROR, "vector_fmul_window failed\n"); + + return ret; +} + +#define ARBITRARY_FMUL_ADD_CONST 0.005 +static int test_vector_fmul_add(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, + const float *v1, const float *v2, const float *v3) +{ + LOCAL_ALIGNED(32, float, cdst, [LEN]); + LOCAL_ALIGNED(32, float, odst, [LEN]); + int ret; + + cdsp->vector_fmul_add(cdst, v1, v2, v3, LEN); + fdsp->vector_fmul_add(odst, v1, v2, v3, LEN); + + if (ret = compare_floats(cdst, odst, LEN, ARBITRARY_FMUL_ADD_CONST)) + av_log(NULL, AV_LOG_ERROR, "vector_fmul_add failed\n"); + + return ret; +} + +static int test_vector_fmul_reverse(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, + const float *v1, const float *v2) +{ + LOCAL_ALIGNED(32, float, cdst, [LEN]); + LOCAL_ALIGNED(32, float, odst, [LEN]); + int ret; + + cdsp->vector_fmul_reverse(cdst, v1, v2, LEN); + fdsp->vector_fmul_reverse(odst, v1, v2, LEN); + + if (ret = compare_floats(cdst, odst, LEN, FLT_EPSILON)) + av_log(NULL, AV_LOG_ERROR, "vector_fmul_reverse failed\n"); + + return ret; +} + +static int test_butterflies_float(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, + const float *v1, const float *v2) +{ + LOCAL_ALIGNED(32, float, cv1, [LEN]); + LOCAL_ALIGNED(32, float, cv2, [LEN]); + LOCAL_ALIGNED(32, float, ov1, [LEN]); + LOCAL_ALIGNED(32, float, ov2, [LEN]); + int ret; + + memcpy(cv1, v1, LEN * sizeof(*v1)); + memcpy(cv2, v2, LEN * sizeof(*v2)); + memcpy(ov1, v1, LEN * sizeof(*v1)); + memcpy(ov2, v2, LEN * sizeof(*v2)); + + cdsp->butterflies_float(cv1, cv2, LEN); + fdsp->butterflies_float(ov1, ov2, LEN); + + if ((ret = compare_floats(cv1, ov1, LEN, FLT_EPSILON)) || + (ret = compare_floats(cv2, ov2, LEN, FLT_EPSILON))) + av_log(NULL, AV_LOG_ERROR, "butterflies_float failed\n"); + + return ret; +} + +#define ARBITRARY_SCALARPRODUCT_CONST 0.2 +static int test_scalarproduct_float(AVFloatDSPContext *fdsp, AVFloatDSPContext *cdsp, + const float *v1, const float *v2) +{ + float cprod, oprod; + int ret; + + cprod = cdsp->scalarproduct_float(v1, v2, LEN); + oprod = fdsp->scalarproduct_float(v1, v2, LEN); + + if (ret = compare_floats(&cprod, &oprod, 1, ARBITRARY_SCALARPRODUCT_CONST)) + av_log(NULL, AV_LOG_ERROR, "scalarproduct_float failed\n"); + + return ret; +} + +int main(int argc, char **argv) +{ + int ret = 0; + uint32_t seed; + AVFloatDSPContext fdsp, cdsp; + AVLFG lfg; + + LOCAL_ALIGNED(32, float, src0, [LEN]); + LOCAL_ALIGNED(32, float, src1, [LEN]); + LOCAL_ALIGNED(32, float, src2, [LEN]); + LOCAL_ALIGNED(32, double, dbl_src0, [LEN]); + LOCAL_ALIGNED(32, double, dbl_src1, [LEN]); + + if (argc > 2 && !strcmp(argv[1], "-s")) + seed = strtoul(argv[2], NULL, 10); + else + seed = av_get_random_seed(); + + av_log(NULL, AV_LOG_INFO, "float_dsp-test: random seed %u\n", seed); + + av_lfg_init(&lfg, seed); + + fill_float_array(&lfg, src0, LEN); + fill_float_array(&lfg, src1, LEN); + fill_float_array(&lfg, src2, LEN); + + fill_double_array(&lfg, dbl_src0, LEN); + fill_double_array(&lfg, dbl_src1, LEN); + + avpriv_float_dsp_init(&fdsp, 1); + av_set_cpu_flags_mask(0); + avpriv_float_dsp_init(&cdsp, 1); + + if (test_vector_fmul(&fdsp, &cdsp, src0, src1)) + ret -= 1 << 0; + if (test_vector_fmac_scalar(&fdsp, &cdsp, src2, src0, src1[0])) + ret -= 1 << 1; + if (test_vector_fmul_scalar(&fdsp, &cdsp, src0, src1[0])) + ret -= 1 << 2; + if (test_vector_fmul_window(&fdsp, &cdsp, src0, src1, src2)) + ret -= 1 << 3; + if (test_vector_fmul_add(&fdsp, &cdsp, src0, src1, src2)) + ret -= 1 << 4; + if (test_vector_fmul_reverse(&fdsp, &cdsp, src0, src1)) + ret -= 1 << 5; + if (test_butterflies_float(&fdsp, &cdsp, src0, src1)) + ret -= 1 << 6; + if (test_scalarproduct_float(&fdsp, &cdsp, src0, src1)) + ret -= 1 << 7; + if (test_vector_dmul_scalar(&fdsp, &cdsp, dbl_src0, dbl_src1[0])) + ret -= 1 << 8; + + return ret; +} + +#endif /* TEST */ diff --git a/chromium/third_party/ffmpeg/libavutil/float_dsp.h b/chromium/third_party/ffmpeg/libavutil/float_dsp.h index d0447d63462..7fc851b6e5f 100644 --- a/chromium/third_party/ffmpeg/libavutil/float_dsp.h +++ b/chromium/third_party/ffmpeg/libavutil/float_dsp.h @@ -113,7 +113,7 @@ typedef struct AVFloatDSPContext { * constraints: 32-byte aligned * @param src1 second input vector * constraints: 32-byte aligned - * @param src1 third input vector + * @param src2 third input vector * constraints: 32-byte aligned * @param len number of elements in the input * constraints: multiple of 16 @@ -132,8 +132,6 @@ typedef struct AVFloatDSPContext { * constraints: 32-byte aligned * @param src1 second input vector * constraints: 32-byte aligned - * @param src1 third input vector - * constraints: 32-byte aligned * @param len number of elements in the input * constraints: multiple of 16 */ @@ -181,6 +179,7 @@ float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len); void avpriv_float_dsp_init(AVFloatDSPContext *fdsp, int strict); +void ff_float_dsp_init_aarch64(AVFloatDSPContext *fdsp); void ff_float_dsp_init_arm(AVFloatDSPContext *fdsp); void ff_float_dsp_init_ppc(AVFloatDSPContext *fdsp, int strict); void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp); diff --git a/chromium/third_party/ffmpeg/libavutil/frame.c b/chromium/third_party/ffmpeg/libavutil/frame.c index 1b44400eb97..9617b10cc59 100644 --- a/chromium/third_party/ffmpeg/libavutil/frame.c +++ b/chromium/third_party/ffmpeg/libavutil/frame.c @@ -159,7 +159,7 @@ static int get_video_buffer(AVFrame *frame, int align) if (i == 1 || i == 2) h = FF_CEIL_RSHIFT(h, desc->log2_chroma_h); - frame->buf[i] = av_buffer_alloc(frame->linesize[i] * h + 16); + frame->buf[i] = av_buffer_alloc(frame->linesize[i] * h + 16 + 16/*STRIDE_ALIGN*/ - 1); if (!frame->buf[i]) goto fail; @@ -204,9 +204,9 @@ static int get_audio_buffer(AVFrame *frame, int align) } if (planes > AV_NUM_DATA_POINTERS) { - frame->extended_data = av_mallocz(planes * + frame->extended_data = av_mallocz_array(planes, sizeof(*frame->extended_data)); - frame->extended_buf = av_mallocz((planes - AV_NUM_DATA_POINTERS) * + frame->extended_buf = av_mallocz_array((planes - AV_NUM_DATA_POINTERS), sizeof(*frame->extended_buf)); if (!frame->extended_data || !frame->extended_buf) { av_freep(&frame->extended_data); @@ -271,16 +271,11 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src) if (ret < 0) return ret; - if (src->nb_samples) { - int ch = src->channels; - CHECK_CHANNELS_CONSISTENCY(src); - av_samples_copy(dst->extended_data, src->extended_data, 0, 0, - dst->nb_samples, ch, dst->format); - } else { - av_image_copy(dst->data, dst->linesize, src->data, src->linesize, - dst->format, dst->width, dst->height); - } - return 0; + ret = av_frame_copy(dst, src); + if (ret < 0) + av_frame_unref(dst); + + return ret; } /* ref the buffers */ @@ -295,7 +290,7 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src) } if (src->extended_buf) { - dst->extended_buf = av_mallocz(sizeof(*dst->extended_buf) * + dst->extended_buf = av_mallocz_array(sizeof(*dst->extended_buf), src->nb_extended_buf); if (!dst->extended_buf) { ret = AVERROR(ENOMEM); @@ -322,7 +317,7 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src) } CHECK_CHANNELS_CONSISTENCY(src); - dst->extended_data = av_malloc(sizeof(*dst->extended_data) * ch); + dst->extended_data = av_malloc_array(sizeof(*dst->extended_data), ch); if (!dst->extended_data) { ret = AVERROR(ENOMEM); goto fail; @@ -424,14 +419,10 @@ int av_frame_make_writable(AVFrame *frame) if (ret < 0) return ret; - if (tmp.nb_samples) { - int ch = tmp.channels; - CHECK_CHANNELS_CONSISTENCY(&tmp); - av_samples_copy(tmp.extended_data, frame->extended_data, 0, 0, - frame->nb_samples, ch, frame->format); - } else { - av_image_copy(tmp.data, tmp.linesize, frame->data, frame->linesize, - frame->format, frame->width, frame->height); + ret = av_frame_copy(&tmp, frame); + if (ret < 0) { + av_frame_unref(&tmp); + return ret; } ret = av_frame_copy_props(&tmp, frame); @@ -592,3 +583,78 @@ AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, } return NULL; } + +static int frame_copy_video(AVFrame *dst, const AVFrame *src) +{ + const uint8_t *src_data[4]; + int i, planes; + + if (dst->width != src->width || + dst->height != src->height) + return AVERROR(EINVAL); + + planes = av_pix_fmt_count_planes(dst->format); + for (i = 0; i < planes; i++) + if (!dst->data[i] || !src->data[i]) + return AVERROR(EINVAL); + + memcpy(src_data, src->data, sizeof(src_data)); + av_image_copy(dst->data, dst->linesize, + src_data, src->linesize, + dst->format, dst->width, dst->height); + + return 0; +} + +static int frame_copy_audio(AVFrame *dst, const AVFrame *src) +{ + int planar = av_sample_fmt_is_planar(dst->format); + int channels = dst->channels; + int planes = planar ? channels : 1; + int i; + + if (dst->nb_samples != src->nb_samples || + dst->channels != src->channels || + dst->channel_layout != src->channel_layout) + return AVERROR(EINVAL); + + CHECK_CHANNELS_CONSISTENCY(src); + + for (i = 0; i < planes; i++) + if (!dst->extended_data[i] || !src->extended_data[i]) + return AVERROR(EINVAL); + + av_samples_copy(dst->extended_data, src->extended_data, 0, 0, + dst->nb_samples, channels, dst->format); + + return 0; +} + +int av_frame_copy(AVFrame *dst, const AVFrame *src) +{ + if (dst->format != src->format || dst->format < 0) + return AVERROR(EINVAL); + + if (dst->width > 0 && dst->height > 0) + return frame_copy_video(dst, src); + else if (dst->nb_samples > 0 && dst->channel_layout) + return frame_copy_audio(dst, src); + + return AVERROR(EINVAL); +} + +void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type) +{ + int i; + + for (i = 0; i < frame->nb_side_data; i++) { + AVFrameSideData *sd = frame->side_data[i]; + if (sd->type == type) { + av_freep(&sd->data); + av_dict_free(&sd->metadata); + av_freep(&frame->side_data[i]); + frame->side_data[i] = frame->side_data[frame->nb_side_data - 1]; + frame->nb_side_data--; + } + } +} diff --git a/chromium/third_party/ffmpeg/libavutil/frame.h b/chromium/third_party/ffmpeg/libavutil/frame.h index b064cc564be..ccc86d72c53 100644 --- a/chromium/third_party/ffmpeg/libavutil/frame.h +++ b/chromium/third_party/ffmpeg/libavutil/frame.h @@ -17,18 +17,24 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +/** + * @file + * @ingroup lavu_frame + * reference-counted frame API + */ + #ifndef AVUTIL_FRAME_H #define AVUTIL_FRAME_H #include <stdint.h> -#include "libavcodec/version.h" - #include "avutil.h" #include "buffer.h" #include "dict.h" #include "rational.h" #include "samplefmt.h" +#include "version.h" + enum AVColorSpace{ AVCOL_SPC_RGB = 0, @@ -53,6 +59,14 @@ enum AVColorRange{ }; +/** + * @defgroup lavu_frame AVFrame + * @ingroup lavu_data + * + * @{ + * AVFrame is an abstraction for reference-counted raw multimedia data. + */ + enum AVFrameSideDataType { /** * The data is the AVPanScan struct defined in libavcodec. @@ -69,6 +83,19 @@ enum AVFrameSideDataType { * The data is the AVStereo3D struct defined in libavutil/stereo3d.h. */ AV_FRAME_DATA_STEREO3D, + /** + * The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h. + */ + AV_FRAME_DATA_MATRIXENCODING, + /** + * Metadata relevant to a downmix procedure. + * The data is the AVDownmixInfo struct defined in libavutil/downmix_info.h. + */ + AV_FRAME_DATA_DOWNMIX_INFO, + /** + * ReplayGain information in the form of the AVReplayGain struct. + */ + AV_FRAME_DATA_REPLAYGAIN, }; typedef struct AVFrameSideData { @@ -181,8 +208,7 @@ typedef struct AVFrame { enum AVPictureType pict_type; #if FF_API_AVFRAME_LAVC - // TODO(wolenetz) Switch to refcounted buffers. See http://crbug.com/236611 - // attribute_deprecated + attribute_deprecated uint8_t *base[AV_NUM_DATA_POINTERS]; #endif @@ -257,7 +283,6 @@ typedef struct AVFrame { * motion_val[direction][x + y*mv_stride][0->mv_x, 1->mv_y]; * @endcode */ - attribute_deprecated int16_t (*motion_val[2])[2]; /** @@ -292,8 +317,7 @@ typedef struct AVFrame { uint64_t error[AV_NUM_DATA_POINTERS]; #if FF_API_AVFRAME_LAVC - // TODO(wolenetz) Switch to refcounted buffers. See http://crbug.com/236611 - // attribute_deprecated + attribute_deprecated int type; #endif @@ -355,7 +379,6 @@ typedef struct AVFrame { * log2 of the size of the block which a single vector in motion_val represents: * (4->16x16, 3->8x8, 2-> 4x4, 1-> 2x2) */ - attribute_deprecated uint8_t motion_subsample_log2; #endif @@ -403,12 +426,22 @@ typedef struct AVFrame { int nb_side_data; /** + * @defgroup lavu_frame_flags AV_FRAME_FLAGS + * Flags describing additional frame properties. + * + * @{ + */ + +/** * The frame data may be corrupted, e.g. due to decoding errors. */ #define AV_FRAME_FLAG_CORRUPT (1 << 0) +/** + * @} + */ /** - * Frame flags, a combination of AV_FRAME_FLAG_* + * Frame flags, a combination of @ref lavu_frame_flags */ int flags; @@ -565,7 +598,7 @@ AVFrame *av_frame_alloc(void); void av_frame_free(AVFrame **frame); /** - * Setup a new reference to the data described by a given frame. + * Set up a new reference to the data described by the source frame. * * Copy frame properties from src to dst and create a new reference for each * AVBufferRef from src. @@ -643,6 +676,19 @@ int av_frame_is_writable(AVFrame *frame); int av_frame_make_writable(AVFrame *frame); /** + * Copy the frame data from src to dst. + * + * This function does not allocate anything, dst must be already initialized and + * allocated with the same parameters as src. + * + * This function only copies the frame data (i.e. the contents of the data / + * extended data arrays), not any other properties. + * + * @return >= 0 on success, a negative AVERROR on error. + */ +int av_frame_copy(AVFrame *dst, const AVFrame *src); + +/** * Copy only "metadata" fields from src to dst. * * Metadata for the purpose of this function are those fields that do not affect @@ -682,4 +728,14 @@ AVFrameSideData *av_frame_new_side_data(AVFrame *frame, AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type); +/** + * If side data of the supplied type exists in the frame, free it and remove it + * from the frame. + */ +void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type); + +/** + * @} + */ + #endif /* AVUTIL_FRAME_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/hash.c b/chromium/third_party/ffmpeg/libavutil/hash.c index a8cf80b577b..773f29e23b5 100644 --- a/chromium/third_party/ffmpeg/libavutil/hash.c +++ b/chromium/third_party/ffmpeg/libavutil/hash.c @@ -29,6 +29,7 @@ #include "sha512.h" #include "avstring.h" +#include "base64.h" #include "error.h" #include "intreadwrite.h" #include "mem.h" @@ -196,6 +197,40 @@ void av_hash_final(AVHashContext *ctx, uint8_t *dst) } } +void av_hash_final_bin(struct AVHashContext *ctx, uint8_t *dst, int size) +{ + uint8_t buf[AV_HASH_MAX_SIZE]; + unsigned rsize = av_hash_get_size(ctx); + + av_hash_final(ctx, buf); + memcpy(dst, buf, FFMIN(size, rsize)); + if (size > rsize) + memset(dst + rsize, 0, size - rsize); +} + +void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size) +{ + uint8_t buf[AV_HASH_MAX_SIZE]; + unsigned rsize = av_hash_get_size(ctx), i; + + av_hash_final(ctx, buf); + for (i = 0; i < FFMIN(rsize, size / 2); i++) + snprintf(dst + i * 2, size - i * 2, "%02x", buf[i]); +} + +void av_hash_final_b64(struct AVHashContext *ctx, uint8_t *dst, int size) +{ + uint8_t buf[AV_HASH_MAX_SIZE], b64[AV_BASE64_SIZE(AV_HASH_MAX_SIZE)]; + unsigned rsize = av_hash_get_size(ctx), osize; + + av_hash_final(ctx, buf); + av_base64_encode(b64, sizeof(b64), buf, rsize); + osize = AV_BASE64_SIZE(rsize); + memcpy(dst, b64, FFMIN(osize, size)); + if (size < osize) + dst[size - 1] = 0; +} + void av_hash_freep(AVHashContext **ctx) { if (*ctx) diff --git a/chromium/third_party/ffmpeg/libavutil/hash.h b/chromium/third_party/ffmpeg/libavutil/hash.h index 9bf715e1ac7..d4bcbf8cc83 100644 --- a/chromium/third_party/ffmpeg/libavutil/hash.h +++ b/chromium/third_party/ffmpeg/libavutil/hash.h @@ -83,6 +83,28 @@ void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, int len); void av_hash_final(struct AVHashContext *ctx, uint8_t *dst); /** + * Finalize a hash context and compute the actual hash value. + * If size is smaller than the hash size, the hash is truncated; + * if size is larger, the buffer is padded with 0. + */ +void av_hash_final_bin(struct AVHashContext *ctx, uint8_t *dst, int size); + +/** + * Finalize a hash context and compute the actual hash value as a hex string. + * The string is always 0-terminated. + * If size is smaller than 2 * hash_size + 1, the hex string is truncated. + */ +void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size); + +/** + * Finalize a hash context and compute the actual hash value as a base64 string. + * The string is always 0-terminated. + * If size is smaller than AV_BASE64_SIZE(hash_size), the base64 string is + * truncated. + */ +void av_hash_final_b64(struct AVHashContext *ctx, uint8_t *dst, int size); + +/** * Free hash context. */ void av_hash_freep(struct AVHashContext **ctx); diff --git a/chromium/third_party/ffmpeg/libavutil/internal.h b/chromium/third_party/ffmpeg/libavutil/internal.h index 9c5546f3b14..ea3c31e4fbc 100644 --- a/chromium/third_party/ffmpeg/libavutil/internal.h +++ b/chromium/third_party/ffmpeg/libavutil/internal.h @@ -93,6 +93,13 @@ // to be forced to tokenize __VA_ARGS__ #define E1(x) x +/* Check if the hard coded offset of a struct member still matches reality. + * Induce a compilation failure if not. + */ +#define AV_CHECK_OFFSET(s, m, o) struct check_##o { \ + int x_##o[offsetof(s, m) == o? 1: -1]; \ + } + #define LOCAL_ALIGNED_A(a, t, v, s, o, ...) \ uint8_t la_##v[sizeof(t s o) + (a)]; \ t (*v) o = (void *)FFALIGN((uintptr_t)la_##v, a) @@ -115,6 +122,12 @@ # define LOCAL_ALIGNED_16(t, v, ...) LOCAL_ALIGNED(16, t, v, __VA_ARGS__) #endif +#if HAVE_LOCAL_ALIGNED_32 +# define LOCAL_ALIGNED_32(t, v, ...) E1(LOCAL_ALIGNED_D(32, t, v, __VA_ARGS__,,)) +#else +# define LOCAL_ALIGNED_32(t, v, ...) LOCAL_ALIGNED(32, t, v, __VA_ARGS__) +#endif + #define FF_ALLOC_OR_GOTO(ctx, p, size, label)\ {\ p = av_malloc(size);\ @@ -133,6 +146,24 @@ }\ } +#define FF_ALLOC_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)\ +{\ + p = av_malloc_array(nelem, elsize);\ + if (p == NULL) {\ + av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ + goto label;\ + }\ +} + +#define FF_ALLOCZ_ARRAY_OR_GOTO(ctx, p, nelem, elsize, label)\ +{\ + p = av_mallocz_array(nelem, elsize);\ + if (p == NULL) {\ + av_log(ctx, AV_LOG_ERROR, "Cannot allocate memory.\n");\ + goto label;\ + }\ +} + #include "libm.h" #if defined(_MSC_VER) @@ -213,6 +244,11 @@ void avpriv_request_sample(void *avc, #if HAVE_LIBC_MSVCRT #define avpriv_open ff_open +#define PTRDIFF_SPECIFIER "Id" +#define SIZE_SPECIFIER "Iu" +#else +#define PTRDIFF_SPECIFIER "td" +#define SIZE_SPECIFIER "zu" #endif /** diff --git a/chromium/third_party/ffmpeg/libavutil/intfloat_readwrite.c b/chromium/third_party/ffmpeg/libavutil/intfloat_readwrite.c index 142331dac10..af5da623cd8 100644 --- a/chromium/third_party/ffmpeg/libavutil/intfloat_readwrite.c +++ b/chromium/third_party/ffmpeg/libavutil/intfloat_readwrite.c @@ -29,7 +29,9 @@ #include "common.h" #include "mathematics.h" #include "intfloat_readwrite.h" +#include "version.h" +#if FF_API_INTFLOAT double av_int2dbl(int64_t v){ if((uint64_t)v+v > 0xFFEULL<<52) return NAN; @@ -96,3 +98,4 @@ AVExtFloat av_dbl2ext(double d){ ext.exponent[0] |= 0x80; return ext; } +#endif /* FF_API_INTFLOAT */ diff --git a/chromium/third_party/ffmpeg/libavutil/intfloat_readwrite.h b/chromium/third_party/ffmpeg/libavutil/intfloat_readwrite.h index 9709f4dae43..1d79e3e8af3 100644 --- a/chromium/third_party/ffmpeg/libavutil/intfloat_readwrite.h +++ b/chromium/third_party/ffmpeg/libavutil/intfloat_readwrite.h @@ -22,8 +22,11 @@ #define AVUTIL_INTFLOAT_READWRITE_H #include <stdint.h> + #include "attributes.h" +#include "version.h" +#if FF_API_INTFLOAT /* IEEE 80 bits extended float */ typedef struct AVExtFloat { uint8_t exponent[2]; @@ -36,5 +39,6 @@ attribute_deprecated double av_ext2dbl(const AVExtFloat ext) av_const; attribute_deprecated int64_t av_dbl2int(double d) av_const; attribute_deprecated int32_t av_flt2int(float d) av_const; attribute_deprecated AVExtFloat av_dbl2ext(double d) av_const; +#endif /* FF_API_INTFLOAT */ #endif /* AVUTIL_INTFLOAT_READWRITE_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/log.c b/chromium/third_party/ffmpeg/libavutil/log.c index a7eb34c3d25..cc51cc01330 100644 --- a/chromium/third_party/ffmpeg/libavutil/log.c +++ b/chromium/third_party/ffmpeg/libavutil/log.c @@ -50,7 +50,7 @@ static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; static int av_log_level = AV_LOG_INFO; static int flags; -#if HAVE_SETCONSOLETEXTATTRIBUTE +#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE #include <windows.h> static const uint8_t color[16 + AV_CLASS_CATEGORY_NB] = { [AV_LOG_PANIC /8] = 12, @@ -71,6 +71,12 @@ static const uint8_t color[16 + AV_CLASS_CATEGORY_NB] = { [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 9, [16+AV_CLASS_CATEGORY_SWSCALER ] = 7, [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 7, + [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 13, + [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 5, + [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 13, + [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 5, + [16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 13, + [16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 5, }; static int16_t background, attr_orig; @@ -96,53 +102,74 @@ static const uint32_t color[16 + AV_CLASS_CATEGORY_NB] = { [16+AV_CLASS_CATEGORY_BITSTREAM_FILTER] = 192 << 8 | 0x14, [16+AV_CLASS_CATEGORY_SWSCALER ] = 153 << 8 | 0x14, [16+AV_CLASS_CATEGORY_SWRESAMPLER ] = 147 << 8 | 0x14, + [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ] = 213 << 8 | 0x15, + [16+AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ] = 207 << 8 | 0x05, + [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ] = 213 << 8 | 0x15, + [16+AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ] = 207 << 8 | 0x05, + [16+AV_CLASS_CATEGORY_DEVICE_OUTPUT ] = 213 << 8 | 0x15, + [16+AV_CLASS_CATEGORY_DEVICE_INPUT ] = 207 << 8 | 0x05, }; #endif static int use_color = -1; -static void colored_fputs(int level, const char *str) +static void check_color_terminal(void) { - if (!*str) - return; - - if (use_color < 0) { -#if HAVE_SETCONSOLETEXTATTRIBUTE - CONSOLE_SCREEN_BUFFER_INFO con_info; - con = GetStdHandle(STD_ERROR_HANDLE); - use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") && - !getenv("AV_LOG_FORCE_NOCOLOR"); - if (use_color) { - GetConsoleScreenBufferInfo(con, &con_info); - attr_orig = con_info.wAttributes; - background = attr_orig & 0xF0; - } +#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE + CONSOLE_SCREEN_BUFFER_INFO con_info; + con = GetStdHandle(STD_ERROR_HANDLE); + use_color = (con != INVALID_HANDLE_VALUE) && !getenv("NO_COLOR") && + !getenv("AV_LOG_FORCE_NOCOLOR"); + if (use_color) { + GetConsoleScreenBufferInfo(con, &con_info); + attr_orig = con_info.wAttributes; + background = attr_orig & 0xF0; + } #elif HAVE_ISATTY - use_color = !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR") && - (getenv("TERM") && isatty(2) || - getenv("AV_LOG_FORCE_COLOR")); - if (getenv("AV_LOG_FORCE_256COLOR")) - use_color *= 256; + char *term = getenv("TERM"); + use_color = !getenv("NO_COLOR") && !getenv("AV_LOG_FORCE_NOCOLOR") && + (getenv("TERM") && isatty(2) || getenv("AV_LOG_FORCE_COLOR")); + if ( getenv("AV_LOG_FORCE_256COLOR") + || (term && strstr(term, "256color"))) + use_color *= 256; #else - use_color = getenv("AV_LOG_FORCE_COLOR") && !getenv("NO_COLOR") && - !getenv("AV_LOG_FORCE_NOCOLOR"); + use_color = getenv("AV_LOG_FORCE_COLOR") && !getenv("NO_COLOR") && + !getenv("AV_LOG_FORCE_NOCOLOR"); #endif - } +} + +static void colored_fputs(int level, int tint, const char *str) +{ + int local_use_color; + if (!*str) + return; + + if (use_color < 0) + check_color_terminal(); -#if HAVE_SETCONSOLETEXTATTRIBUTE - if (use_color && level != AV_LOG_INFO/8) + if (level == AV_LOG_INFO/8) local_use_color = 0; + else local_use_color = use_color; + +#if defined(_WIN32) && !defined(__MINGW32CE__) && HAVE_SETCONSOLETEXTATTRIBUTE + if (local_use_color) SetConsoleTextAttribute(con, background | color[level]); fputs(str, stderr); - if (use_color && level != AV_LOG_INFO/8) + if (local_use_color) SetConsoleTextAttribute(con, attr_orig); #else - if (use_color == 1 && level != AV_LOG_INFO/8) { + if (local_use_color == 1) { fprintf(stderr, "\033[%d;3%dm%s\033[0m", (color[level] >> 4) & 15, color[level] & 15, str); - } else if (use_color == 256 && level != AV_LOG_INFO/8) { + } else if (tint && use_color == 256) { + fprintf(stderr, + "\033[48;5;%dm\033[38;5;%dm%s\033[0m", + (color[level] >> 16) & 0xff, + tint, + str); + } else if (local_use_color == 256) { fprintf(stderr, "\033[48;5;%dm\033[38;5;%dm%s\033[0m", (color[level] >> 16) & 0xff, @@ -185,18 +212,43 @@ static int get_category(void *ptr){ return avc->category + 16; } -static void format_line(void *ptr, int level, const char *fmt, va_list vl, - AVBPrint part[3], int *print_prefix, int type[2]) +static const char *get_level_str(int level) { - AVClass* avc = ptr ? *(AVClass **) ptr : NULL; + switch (level) { + case AV_LOG_QUIET: + return "quiet"; + case AV_LOG_DEBUG: + return "debug"; + case AV_LOG_VERBOSE: + return "verbose"; + case AV_LOG_INFO: + return "info"; + case AV_LOG_WARNING: + return "warning"; + case AV_LOG_ERROR: + return "error"; + case AV_LOG_FATAL: + return "fatal"; + case AV_LOG_PANIC: + return "panic"; + default: + return ""; + } +} + +static void format_line(void *avcl, int level, const char *fmt, va_list vl, + AVBPrint part[4], int *print_prefix, int type[2]) +{ + AVClass* avc = avcl ? *(AVClass **) avcl : NULL; av_bprint_init(part+0, 0, 1); av_bprint_init(part+1, 0, 1); - av_bprint_init(part+2, 0, 65536); + av_bprint_init(part+2, 0, 1); + av_bprint_init(part+3, 0, 65536); if(type) type[0] = type[1] = AV_CLASS_CATEGORY_NA + 16; if (*print_prefix && avc) { if (avc->parent_log_context_offset) { - AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) + + AVClass** parent = *(AVClass ***) (((uint8_t *) avcl) + avc->parent_log_context_offset); if (parent && *parent) { av_bprintf(part+0, "[%s @ %p] ", @@ -205,14 +257,17 @@ static void format_line(void *ptr, int level, const char *fmt, va_list vl, } } av_bprintf(part+1, "[%s @ %p] ", - avc->item_name(ptr), ptr); - if(type) type[1] = get_category(ptr); + avc->item_name(avcl), avcl); + if(type) type[1] = get_category(avcl); + + if (flags & AV_LOG_PRINT_LEVEL) + av_bprintf(part+2, "[%s] ", get_level_str(level)); } - av_vbprintf(part+2, fmt, vl); + av_vbprintf(part+3, fmt, vl); - if(*part[0].str || *part[1].str || *part[2].str) { - char lastc = part[2].len && part[2].len <= part[2].size ? part[2].str[part[2].len - 1] : 0; + if(*part[0].str || *part[1].str || *part[2].str || *part[3].str) { + char lastc = part[3].len && part[3].len <= part[3].size ? part[3].str[part[3].len - 1] : 0; *print_prefix = lastc == '\n' || lastc == '\r'; } } @@ -220,10 +275,10 @@ static void format_line(void *ptr, int level, const char *fmt, va_list vl, void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, char *line, int line_size, int *print_prefix) { - AVBPrint part[3]; + AVBPrint part[4]; format_line(ptr, level, fmt, vl, part, print_prefix, NULL); - snprintf(line, line_size, "%s%s%s", part[0].str, part[1].str, part[2].str); - av_bprint_finalize(part+2, NULL); + snprintf(line, line_size, "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str); + av_bprint_finalize(part+3, NULL); } void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) @@ -231,10 +286,16 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) static int print_prefix = 1; static int count; static char prev[LINE_SZ]; - AVBPrint part[3]; + AVBPrint part[4]; char line[LINE_SZ]; static int is_atty; int type[2]; + unsigned tint = 0; + + if (level >= 0) { + tint = level & 0xff00; + level &= 0xff; + } if (level > av_log_level) return; @@ -243,7 +304,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) #endif format_line(ptr, level, fmt, vl, part, &print_prefix, type); - snprintf(line, sizeof(line), "%s%s%s", part[0].str, part[1].str, part[2].str); + snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str); #if HAVE_ISATTY if (!is_atty) @@ -263,13 +324,15 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) } strcpy(prev, line); sanitize(part[0].str); - colored_fputs(type[0], part[0].str); + colored_fputs(type[0], 0, part[0].str); sanitize(part[1].str); - colored_fputs(type[1], part[1].str); + colored_fputs(type[1], 0, part[1].str); sanitize(part[2].str); - colored_fputs(av_clip(level >> 3, 0, 6), part[2].str); + colored_fputs(av_clip(level >> 3, 0, 6), tint >> 8, part[2].str); + sanitize(part[3].str); + colored_fputs(av_clip(level >> 3, 0, 6), tint >> 8, part[3].str); end: - av_bprint_finalize(part+2, NULL); + av_bprint_finalize(part+3, NULL); #if HAVE_PTHREADS pthread_mutex_unlock(&mutex); #endif @@ -312,6 +375,11 @@ void av_log_set_flags(int arg) flags = arg; } +int av_log_get_flags(void) +{ + return flags; +} + void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)) { av_log_callback = callback; @@ -348,3 +416,26 @@ void avpriv_report_missing_feature(void *avc, const char *msg, ...) missing_feature_sample(0, avc, msg, argument_list); va_end(argument_list); } + +#ifdef TEST +// LCOV_EXCL_START +#include <string.h> + +int main(int argc, char **argv) +{ + int i; + av_log_set_level(AV_LOG_DEBUG); + for (use_color=0; use_color<=256; use_color = 255*use_color+1) { + av_log(NULL, AV_LOG_FATAL, "use_color: %d\n", use_color); + for (i = AV_LOG_DEBUG; i>=AV_LOG_QUIET; i-=8) { + av_log(NULL, i, " %d", i); + av_log(NULL, AV_LOG_INFO, "e "); + av_log(NULL, i + 256*123, "C%d", i); + av_log(NULL, AV_LOG_INFO, "e"); + } + av_log(NULL, AV_LOG_PANIC, "\n"); + } + return 0; +} +// LCOV_EXCL_STOP +#endif diff --git a/chromium/third_party/ffmpeg/libavutil/log.h b/chromium/third_party/ffmpeg/libavutil/log.h index 55459e811a0..a6a07e0653a 100644 --- a/chromium/third_party/ffmpeg/libavutil/log.h +++ b/chromium/third_party/ffmpeg/libavutil/log.h @@ -37,6 +37,12 @@ typedef enum { AV_CLASS_CATEGORY_BITSTREAM_FILTER, AV_CLASS_CATEGORY_SWSCALER, AV_CLASS_CATEGORY_SWRESAMPLER, + AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT = 40, + AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT, + AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT, + AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT, + AV_CLASS_CATEGORY_DEVICE_OUTPUT, + AV_CLASS_CATEGORY_DEVICE_INPUT, AV_CLASS_CATEGORY_NB, ///< not part of ABI/API }AVClassCategory; @@ -186,6 +192,16 @@ typedef struct AVClass { */ /** + * Sets additional colors for extended debugging sessions. + * @code + av_log(ctx, AV_LOG_DEBUG|AV_LOG_C(134), "Message in purple\n"); + @endcode + * Requires 256color terminal support. Uses outside debugging is not + * recommended. + */ +#define AV_LOG_C(x) (x << 8) + +/** * Send the specified message to the log if the level is less than or equal * to the current av_log_level. By default, all logging messages are sent to * stderr. This behavior can be altered by setting a different logging callback @@ -260,9 +276,10 @@ void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)); * lavu_log_constants "Logging Constant". * @param fmt The format string (printf-compatible) that specifies how * subsequent arguments are converted to output. - * @param ap The arguments referenced by the format string. + * @param vl The arguments referenced by the format string. */ -void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl); +void av_log_default_callback(void *avcl, int level, const char *fmt, + va_list vl); /** * Return the context name @@ -304,7 +321,17 @@ void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, * call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end */ #define AV_LOG_SKIP_REPEATED 1 + +/** + * Include the log severity in messages originating from codecs. + * + * Results in messages such as: + * [rawvideo @ 0xDEADBEEF] [error] encode did not produce valid pts + */ +#define AV_LOG_PRINT_LEVEL 2 + void av_log_set_flags(int arg); +int av_log_get_flags(void); /** * @} diff --git a/chromium/third_party/ffmpeg/libavutil/macros.h b/chromium/third_party/ffmpeg/libavutil/macros.h new file mode 100644 index 00000000000..446532377a6 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/macros.h @@ -0,0 +1,48 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @ingroup lavu + * Utility Preprocessor macros + */ + +#ifndef AVUTIL_MACROS_H +#define AVUTIL_MACROS_H + +/** + * @addtogroup preproc_misc Preprocessor String Macros + * + * String manipulation macros + * + * @{ + */ + +#define AV_STRINGIFY(s) AV_TOSTRING(s) +#define AV_TOSTRING(s) #s + +#define AV_GLUE(a, b) a ## b +#define AV_JOIN(a, b) AV_GLUE(a, b) + +/** + * @} + */ + +#define AV_PRAGMA(s) _Pragma(#s) + +#endif /* AVUTIL_MACROS_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/mathematics.c b/chromium/third_party/ffmpeg/libavutil/mathematics.c index f9cf87da803..81841f79d2e 100644 --- a/chromium/third_party/ffmpeg/libavutil/mathematics.c +++ b/chromium/third_party/ffmpeg/libavutil/mathematics.c @@ -32,7 +32,7 @@ #include "version.h" #if FF_API_AV_REVERSE -const uint8_t av_reverse[256]={ +const uint8_t av_reverse[256] = { 0x00,0x80,0x40,0xC0,0x20,0xA0,0x60,0xE0,0x10,0x90,0x50,0xD0,0x30,0xB0,0x70,0xF0, 0x08,0x88,0x48,0xC8,0x28,0xA8,0x68,0xE8,0x18,0x98,0x58,0xD8,0x38,0xB8,0x78,0xF8, 0x04,0x84,0x44,0xC4,0x24,0xA4,0x64,0xE4,0x14,0x94,0x54,0xD4,0x34,0xB4,0x74,0xF4, @@ -52,53 +52,62 @@ const uint8_t av_reverse[256]={ }; #endif -int64_t av_gcd(int64_t a, int64_t b){ - if(b) return av_gcd(b, a%b); - else return a; +int64_t av_gcd(int64_t a, int64_t b) +{ + if (b) + return av_gcd(b, a % b); + else + return a; } -int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){ - int64_t r=0; +int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd) +{ + int64_t r = 0; av_assert2(c > 0); av_assert2(b >=0); av_assert2((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4); + if (c <= 0 || b < 0 || !((unsigned)(rnd&~AV_ROUND_PASS_MINMAX)<=5 && (rnd&~AV_ROUND_PASS_MINMAX)!=4)) + return INT64_MIN; + if (rnd & AV_ROUND_PASS_MINMAX) { if (a == INT64_MIN || a == INT64_MAX) return a; rnd -= AV_ROUND_PASS_MINMAX; } - if(a<0 && a != INT64_MIN) return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd>>1)&1)); + if (a < 0 && a != INT64_MIN) + return -av_rescale_rnd(-a, b, c, rnd ^ ((rnd >> 1) & 1)); - if(rnd==AV_ROUND_NEAR_INF) r= c/2; - else if(rnd&1) r= c-1; + if (rnd == AV_ROUND_NEAR_INF) + r = c / 2; + else if (rnd & 1) + r = c - 1; - if(b<=INT_MAX && c<=INT_MAX){ - if(a<=INT_MAX) - return (a * b + r)/c; + if (b <= INT_MAX && c <= INT_MAX) { + if (a <= INT_MAX) + return (a * b + r) / c; else - return a/c*b + (a%c*b + r)/c; - }else{ + return a / c * b + (a % c * b + r) / c; + } else { #if 1 - uint64_t a0= a&0xFFFFFFFF; - uint64_t a1= a>>32; - uint64_t b0= b&0xFFFFFFFF; - uint64_t b1= b>>32; - uint64_t t1= a0*b1 + a1*b0; - uint64_t t1a= t1<<32; + uint64_t a0 = a & 0xFFFFFFFF; + uint64_t a1 = a >> 32; + uint64_t b0 = b & 0xFFFFFFFF; + uint64_t b1 = b >> 32; + uint64_t t1 = a0 * b1 + a1 * b0; + uint64_t t1a = t1 << 32; int i; - a0 = a0*b0 + t1a; - a1 = a1*b1 + (t1>>32) + (a0<t1a); + a0 = a0 * b0 + t1a; + a1 = a1 * b1 + (t1 >> 32) + (a0 < t1a); a0 += r; - a1 += a0<r; + a1 += a0 < r; - for(i=63; i>=0; i--){ -// int o= a1 & 0x8000000000000000ULL; - a1+= a1 + ((a0>>i)&1); - t1+=t1; - if(/*o || */c <= a1){ + for (i = 63; i >= 0; i--) { + a1 += a1 + ((a0 >> i) & 1); + t1 += t1; + if (c <= a1) { a1 -= c; t1++; } @@ -107,23 +116,24 @@ int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){ } #else AVInteger ai; - ai= av_mul_i(av_int2i(a), av_int2i(b)); - ai= av_add_i(ai, av_int2i(r)); + ai = av_mul_i(av_int2i(a), av_int2i(b)); + ai = av_add_i(ai, av_int2i(r)); return av_i2int(av_div_i(ai, av_int2i(c))); } #endif } -int64_t av_rescale(int64_t a, int64_t b, int64_t c){ +int64_t av_rescale(int64_t a, int64_t b, int64_t c) +{ return av_rescale_rnd(a, b, c, AV_ROUND_NEAR_INF); } int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd) { - int64_t b= bq.num * (int64_t)cq.den; - int64_t c= cq.num * (int64_t)bq.den; + int64_t b = bq.num * (int64_t)cq.den; + int64_t c = cq.num * (int64_t)bq.den; return av_rescale_rnd(a, b, c, rnd); } @@ -132,20 +142,24 @@ int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) return av_rescale_q_rnd(a, bq, cq, AV_ROUND_NEAR_INF); } -int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b){ - int64_t a= tb_a.num * (int64_t)tb_b.den; - int64_t b= tb_b.num * (int64_t)tb_a.den; - if((FFABS(ts_a)|a|FFABS(ts_b)|b)<=INT_MAX) +int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b) +{ + int64_t a = tb_a.num * (int64_t)tb_b.den; + int64_t b = tb_b.num * (int64_t)tb_a.den; + if ((FFABS(ts_a)|a|FFABS(ts_b)|b) <= INT_MAX) return (ts_a*a > ts_b*b) - (ts_a*a < ts_b*b); - if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) return -1; - if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) return 1; + if (av_rescale_rnd(ts_a, a, b, AV_ROUND_DOWN) < ts_b) + return -1; + if (av_rescale_rnd(ts_b, b, a, AV_ROUND_DOWN) < ts_a) + return 1; return 0; } -int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod){ - int64_t c= (a-b) & (mod-1); - if(c > (mod>>1)) - c-= mod; +int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod) +{ + int64_t c = (a - b) & (mod - 1); + if (c > (mod >> 1)) + c -= mod; return c; } @@ -171,3 +185,17 @@ simple_round: return av_rescale_q(this, fs_tb, out_tb); } + +int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc) +{ + AVRational step = av_mul_q(inc_tb, (AVRational) {inc, 1}); + + if (av_cmp_q(step, ts_tb) < 0) { + //increase step is too small for even 1 step to be representable + return ts; + } else { + int64_t old = av_rescale_q(ts, ts_tb, step); + int64_t old_ts = av_rescale_q(old, step, ts_tb); + return av_rescale_q(old + 1, step, ts_tb) + (ts - old_ts); + } +} diff --git a/chromium/third_party/ffmpeg/libavutil/mathematics.h b/chromium/third_party/ffmpeg/libavutil/mathematics.h index 71f0392218d..88739e80b8f 100644 --- a/chromium/third_party/ffmpeg/libavutil/mathematics.h +++ b/chromium/third_party/ffmpeg/libavutil/mathematics.h @@ -45,6 +45,9 @@ #ifndef M_PI #define M_PI 3.14159265358979323846 /* pi */ #endif +#ifndef M_PI_2 +#define M_PI_2 1.57079632679489661923 /* pi/2 */ +#endif #ifndef M_SQRT1_2 #define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #endif @@ -133,14 +136,28 @@ int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod); * Rescale a timestamp while preserving known durations. * * @param in_ts Input timestamp - * @param in_tb Input timesbase + * @param in_tb Input timebase * @param fs_tb Duration and *last timebase * @param duration duration till the next call - * @param out_tb Output timesbase + * @param out_tb Output timebase */ int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb); /** + * Add a value to a timestamp. + * + * This function gurantees that when the same value is repeatly added that + * no accumulation of rounding errors occurs. + * + * @param ts Input timestamp + * @param ts_tb Input timestamp timebase + * @param inc value to add to ts + * @param inc_tb inc timebase + */ +int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc); + + + /** * @} */ diff --git a/chromium/third_party/ffmpeg/libavutil/mem.c b/chromium/third_party/ffmpeg/libavutil/mem.c index 10b0137a7e2..8226168eedc 100644 --- a/chromium/third_party/ffmpeg/libavutil/mem.c +++ b/chromium/third_party/ffmpeg/libavutil/mem.c @@ -39,6 +39,7 @@ #include "avassert.h" #include "avutil.h" #include "common.h" +#include "dynarray.h" #include "intreadwrite.h" #include "mem.h" @@ -277,67 +278,48 @@ void *av_memdup(const void *p, size_t size) return ptr; } -void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem) +int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem) { - /* see similar ffmpeg.c:grow_array() */ - int nb, nb_alloc; - intptr_t *tab; - - nb = *nb_ptr; - tab = *(intptr_t**)tab_ptr; - if ((nb & (nb - 1)) == 0) { - if (nb == 0) { - nb_alloc = 1; - } else { - if (nb > INT_MAX / (2 * sizeof(intptr_t))) - goto fail; - nb_alloc = nb * 2; - } - tab = av_realloc(tab, nb_alloc * sizeof(intptr_t)); - if (!tab) - goto fail; - *(intptr_t**)tab_ptr = tab; - } - tab[nb++] = (intptr_t)elem; - *nb_ptr = nb; - return; + void **tab = *(void ***)tab_ptr; + + AV_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, { + tab[*nb_ptr] = elem; + *(void ***)tab_ptr = tab; + }, { + return AVERROR(ENOMEM); + }); + return 0; +} -fail: - av_freep(tab_ptr); - *nb_ptr = 0; +void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem) +{ + void **tab = *(void ***)tab_ptr; + + AV_DYNARRAY_ADD(INT_MAX, sizeof(*tab), tab, *nb_ptr, { + tab[*nb_ptr] = elem; + *(void ***)tab_ptr = tab; + }, { + *nb_ptr = 0; + av_freep(tab_ptr); + }); } void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size, const uint8_t *elem_data) { - int nb = *nb_ptr, nb_alloc; - uint8_t *tab = *tab_ptr, *tab_elem_data; - - if ((nb & (nb - 1)) == 0) { - if (nb == 0) { - nb_alloc = 1; - } else { - if (nb > INT_MAX / (2 * elem_size)) - goto fail; - nb_alloc = nb * 2; - } - tab = av_realloc(tab, nb_alloc * elem_size); - if (!tab) - goto fail; - *tab_ptr = tab; - } - *nb_ptr = nb + 1; - tab_elem_data = tab + nb*elem_size; - if (elem_data) - memcpy(tab_elem_data, elem_data, elem_size); - else if (CONFIG_MEMORY_POISONING) - memset(tab_elem_data, FF_MEMORY_POISON, elem_size); + uint8_t *tab_elem_data = NULL; + + AV_DYNARRAY_ADD(INT_MAX, elem_size, *tab_ptr, *nb_ptr, { + tab_elem_data = (uint8_t *)*tab_ptr + (*nb_ptr) * elem_size; + if (elem_data) + memcpy(tab_elem_data, elem_data, elem_size); + else if (CONFIG_MEMORY_POISONING) + memset(tab_elem_data, FF_MEMORY_POISON, elem_size); + }, { + av_freep(tab_ptr); + *nb_ptr = 0; + }); return tab_elem_data; - -fail: - av_freep(tab_ptr); - *nb_ptr = 0; - return NULL; } static void fill16(uint8_t *dst, int len) diff --git a/chromium/third_party/ffmpeg/libavutil/mem.h b/chromium/third_party/ffmpeg/libavutil/mem.h index 703ce819364..801c53ff512 100644 --- a/chromium/third_party/ffmpeg/libavutil/mem.h +++ b/chromium/third_party/ffmpeg/libavutil/mem.h @@ -276,11 +276,26 @@ void av_freep(void *ptr); * @param tab_ptr pointer to the array to grow * @param nb_ptr pointer to the number of elements in the array * @param elem element to add - * @see av_dynarray2_add() + * @see av_dynarray_add_nofree(), av_dynarray2_add() */ void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem); /** + * Add an element to a dynamic array. + * + * Function has the same functionality as av_dynarray_add(), + * but it doesn't free memory on fails. It returns error code + * instead and leave current buffer untouched. + * + * @param tab_ptr pointer to the array to grow + * @param nb_ptr pointer to the number of elements in the array + * @param elem element to add + * @return >=0 on success, negative otherwise. + * @see av_dynarray_add(), av_dynarray2_add() + */ +int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem); + +/** * Add an element of size elem_size to a dynamic array. * * The array is reallocated when its number of elements reaches powers of 2. @@ -299,7 +314,7 @@ void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem); * the new added element is not filled. * @return pointer to the data of the element to copy in the new allocated space. * If NULL, the new allocated space is left uninitialized." - * @see av_dynarray_add() + * @see av_dynarray_add(), av_dynarray_add_nofree() */ void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size, const uint8_t *elem_data); diff --git a/chromium/third_party/ffmpeg/libavutil/opencl.c b/chromium/third_party/ffmpeg/libavutil/opencl.c index 142c6b0bf21..a92bce76b46 100644 --- a/chromium/third_party/ffmpeg/libavutil/opencl.c +++ b/chromium/third_party/ffmpeg/libavutil/opencl.c @@ -27,15 +27,20 @@ #include "avassert.h" #include "opt.h" +#if HAVE_THREADS #if HAVE_PTHREADS - #include <pthread.h> -static pthread_mutex_t atomic_opencl_lock = PTHREAD_MUTEX_INITIALIZER; - -#define LOCK_OPENCL pthread_mutex_lock(&atomic_opencl_lock) -#define UNLOCK_OPENCL pthread_mutex_unlock(&atomic_opencl_lock) +#elif HAVE_W32THREADS +#include "compat/w32pthreads.h" +#elif HAVE_OS2THREADS +#include "compat/os2threads.h" +#endif +#include "atomic.h" -#elif !HAVE_THREADS +static volatile pthread_mutex_t *atomic_opencl_lock = NULL; +#define LOCK_OPENCL pthread_mutex_lock(atomic_opencl_lock) +#define UNLOCK_OPENCL pthread_mutex_unlock(atomic_opencl_lock) +#else #define LOCK_OPENCL #define UNLOCK_OPENCL #endif @@ -169,7 +174,7 @@ static const OpenclErrorMsg opencl_err_msg[] = { const char *av_opencl_errstr(cl_int status) { int i; - for (i = 0; i < sizeof(opencl_err_msg); i++) { + for (i = 0; i < FF_ARRAY_ELEMS(opencl_err_msg); i++) { if (opencl_err_msg[i].err_code == status) return opencl_err_msg[i].err_str; } @@ -321,9 +326,32 @@ void av_opencl_free_device_list(AVOpenCLDeviceList **device_list) av_freep(device_list); } +static inline int init_opencl_mtx(void) +{ +#if HAVE_THREADS + if (!atomic_opencl_lock) { + int err; + pthread_mutex_t *tmp = av_malloc(sizeof(pthread_mutex_t)); + if (!tmp) + return AVERROR(ENOMEM); + if ((err = pthread_mutex_init(tmp, NULL))) { + av_free(tmp); + return AVERROR(err); + } + if (avpriv_atomic_ptr_cas(&atomic_opencl_lock, NULL, tmp)) { + pthread_mutex_destroy(tmp); + av_free(tmp); + } + } +#endif + return 0; +} + int av_opencl_set_option(const char *key, const char *val) { - int ret = 0; + int ret = init_opencl_mtx( ); + if (ret < 0) + return ret; LOCK_OPENCL; if (!opencl_ctx.opt_init_flag) { av_opt_set_defaults(&opencl_ctx); @@ -368,7 +396,9 @@ void av_opencl_free_external_env(AVOpenCLExternalEnv **ext_opencl_env) int av_opencl_register_kernel_code(const char *kernel_code) { - int i, ret = 0; + int i, ret = init_opencl_mtx( ); + if (ret < 0) + return ret; LOCK_OPENCL; if (opencl_ctx.kernel_code_count >= MAX_KERNEL_CODE_NUM) { av_log(&opencl_ctx, AV_LOG_ERROR, @@ -553,7 +583,9 @@ static int init_opencl_env(OpenclContext *opencl_ctx, AVOpenCLExternalEnv *ext_o int av_opencl_init(AVOpenCLExternalEnv *ext_opencl_env) { - int ret = 0; + int ret = init_opencl_mtx( ); + if (ret < 0) + return ret; LOCK_OPENCL; if (!opencl_ctx.init_count) { if (!opencl_ctx.opt_init_flag) { diff --git a/chromium/third_party/ffmpeg/libavutil/opencl.h b/chromium/third_party/ffmpeg/libavutil/opencl.h index cf0abd79751..9e6dc55ee8a 100644 --- a/chromium/third_party/ffmpeg/libavutil/opencl.h +++ b/chromium/third_party/ffmpeg/libavutil/opencl.h @@ -38,6 +38,7 @@ #else #include <OpenCL/cl.h> #endif +#include <stdint.h> #include "dict.h" #include "libavutil/version.h" diff --git a/chromium/third_party/ffmpeg/libavutil/opt.c b/chromium/third_party/ffmpeg/libavutil/opt.c index f6aa496b8c0..199eadbc05d 100644 --- a/chromium/third_party/ffmpeg/libavutil/opt.c +++ b/chromium/third_party/ffmpeg/libavutil/opt.c @@ -195,6 +195,15 @@ static int set_string(void *obj, const AVOption *o, const char *val, uint8_t **d static int set_string_number(void *obj, void *target_obj, const AVOption *o, const char *val, void *dst) { int ret = 0, notfirst = 0; + int num, den; + char c; + + if (sscanf(val, "%d%*1[:/]%d%c", &num, &den, &c) == 2) { + if ((ret = write_number(obj, o, dst, 1, den, num)) >= 0) + return ret; + ret = 0; + } + for (;;) { int i, den = 1; char buf[256]; @@ -295,6 +304,58 @@ static int set_string_color(void *obj, const AVOption *o, const char *val, uint8 return 0; } +static int set_string_fmt(void *obj, const AVOption *o, const char *val, uint8_t *dst, + int fmt_nb, int ((*get_fmt)(const char *)), const char *desc) +{ + int fmt, min, max; + + if (!val || !strcmp(val, "none")) { + fmt = -1; + } else { + fmt = get_fmt(val); + if (fmt == -1) { + char *tail; + fmt = strtol(val, &tail, 0); + if (*tail || (unsigned)fmt >= fmt_nb) { + av_log(obj, AV_LOG_ERROR, + "Unable to parse option value \"%s\" as %s\n", val, desc); + return AVERROR(EINVAL); + } + } + } + + min = FFMAX(o->min, -1); + max = FFMIN(o->max, fmt_nb-1); + + // hack for compatibility with old ffmpeg + if(min == 0 && max == 0) { + min = -1; + max = fmt_nb-1; + } + + if (fmt < min || fmt > max) { + av_log(obj, AV_LOG_ERROR, + "Value %d for parameter '%s' out of %s format range [%d - %d]\n", + fmt, o->name, desc, min, max); + return AVERROR(ERANGE); + } + + *(int *)dst = fmt; + return 0; +} + +static int set_string_pixel_fmt(void *obj, const AVOption *o, const char *val, uint8_t *dst) +{ + return set_string_fmt(obj, o, val, dst, + AV_PIX_FMT_NB, av_get_pix_fmt, "pixel format"); +} + +static int set_string_sample_fmt(void *obj, const AVOption *o, const char *val, uint8_t *dst) +{ + return set_string_fmt(obj, o, val, dst, + AV_SAMPLE_FMT_NB, av_get_sample_fmt, "sample format"); +} + #if FF_API_OLD_AVOPTIONS int av_set_string3(void *obj, const char *name, const char *val, int alloc, const AVOption **o_out) { @@ -319,6 +380,9 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) o->type != AV_OPT_TYPE_CHANNEL_LAYOUT)) return AVERROR(EINVAL); + if (o->flags & AV_OPT_FLAG_READONLY) + return AVERROR(EINVAL); + dst = ((uint8_t*)target_obj) + o->offset; switch (o->type) { case AV_OPT_TYPE_STRING: return set_string(obj, o, val, dst); @@ -331,38 +395,8 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) case AV_OPT_TYPE_RATIONAL: return set_string_number(obj, target_obj, o, val, dst); case AV_OPT_TYPE_IMAGE_SIZE: return set_string_image_size(obj, o, val, dst); case AV_OPT_TYPE_VIDEO_RATE: return set_string_video_rate(obj, o, val, dst); - case AV_OPT_TYPE_PIXEL_FMT: - if (!val || !strcmp(val, "none")) { - ret = AV_PIX_FMT_NONE; - } else { - ret = av_get_pix_fmt(val); - if (ret == AV_PIX_FMT_NONE) { - char *tail; - ret = strtol(val, &tail, 0); - if (*tail || (unsigned)ret >= AV_PIX_FMT_NB) { - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as pixel format\n", val); - return AVERROR(EINVAL); - } - } - } - *(enum AVPixelFormat *)dst = ret; - return 0; - case AV_OPT_TYPE_SAMPLE_FMT: - if (!val || !strcmp(val, "none")) { - ret = AV_SAMPLE_FMT_NONE; - } else { - ret = av_get_sample_fmt(val); - if (ret == AV_SAMPLE_FMT_NONE) { - char *tail; - ret = strtol(val, &tail, 0); - if (*tail || (unsigned)ret >= AV_SAMPLE_FMT_NB) { - av_log(obj, AV_LOG_ERROR, "Unable to parse option value \"%s\" as sample format\n", val); - return AVERROR(EINVAL); - } - } - } - *(enum AVSampleFormat *)dst = ret; - return 0; + case AV_OPT_TYPE_PIXEL_FMT: return set_string_pixel_fmt(obj, o, val, dst); + case AV_OPT_TYPE_SAMPLE_FMT: return set_string_sample_fmt(obj, o, val, dst); case AV_OPT_TYPE_DURATION: if (!val) { *(int64_t *)dst = 0; @@ -400,7 +434,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags) #define OPT_EVAL_NUMBER(name, opttype, vartype)\ int av_opt_eval_ ## name(void *obj, const AVOption *o, const char *val, vartype *name ## _out)\ {\ - if (!o || o->type != opttype)\ + if (!o || o->type != opttype || o->flags & AV_OPT_FLAG_READONLY)\ return AVERROR(EINVAL);\ return set_string_number(obj, obj, o, val, name ## _out);\ } @@ -421,6 +455,9 @@ static int set_number(void *obj, const char *name, double num, int den, int64_t if (!o || !target_obj) return AVERROR_OPTION_NOT_FOUND; + if (o->flags & AV_OPT_FLAG_READONLY) + return AVERROR(EINVAL); + dst = ((uint8_t*)target_obj) + o->offset; return write_number(obj, o, dst, num, den, intnum); } @@ -477,7 +514,7 @@ int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int if (!o || !target_obj) return AVERROR_OPTION_NOT_FOUND; - if (o->type != AV_OPT_TYPE_BINARY) + if (o->type != AV_OPT_TYPE_BINARY || o->flags & AV_OPT_FLAG_READONLY) return AVERROR(EINVAL); ptr = len ? av_malloc(len) : NULL; @@ -552,15 +589,15 @@ static int set_format(void *obj, const char *name, int fmt, int search_flags, return AVERROR(EINVAL); } -#if LIBAVUTIL_VERSION_MAJOR < 53 +#if LIBAVUTIL_VERSION_MAJOR < 54 if (class->version && class->version < AV_VERSION_INT(52, 11, 100)) { min = -1; max = nb_fmts-1; } else #endif { - min = FFMIN(o->min, -1); - max = FFMAX(o->max, nb_fmts-1); + min = FFMAX(o->min, -1); + max = FFMIN(o->max, nb_fmts-1); } if (fmt < min || fmt > max) { av_log(obj, AV_LOG_ERROR, @@ -905,6 +942,8 @@ static void log_value(void *av_log_obj, int level, double d) av_log(av_log_obj, level, "INT_MAX"); } else if (d == INT_MIN) { av_log(av_log_obj, level, "INT_MIN"); + } else if (d == UINT32_MAX) { + av_log(av_log_obj, level, "UINT32_MAX"); } else if (d == (double)INT64_MAX) { av_log(av_log_obj, level, "I64_MAX"); } else if (d == INT64_MIN) { @@ -913,6 +952,18 @@ static void log_value(void *av_log_obj, int level, double d) av_log(av_log_obj, level, "FLT_MAX"); } else if (d == FLT_MIN) { av_log(av_log_obj, level, "FLT_MIN"); + } else if (d == -FLT_MAX) { + av_log(av_log_obj, level, "-FLT_MAX"); + } else if (d == -FLT_MIN) { + av_log(av_log_obj, level, "-FLT_MIN"); + } else if (d == DBL_MAX) { + av_log(av_log_obj, level, "DBL_MAX"); + } else if (d == DBL_MIN) { + av_log(av_log_obj, level, "DBL_MIN"); + } else if (d == -DBL_MAX) { + av_log(av_log_obj, level, "-DBL_MAX"); + } else if (d == -DBL_MIN) { + av_log(av_log_obj, level, "-DBL_MIN"); } else { av_log(av_log_obj, level, "%g", d); } @@ -1003,6 +1054,8 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit, av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM ) ? 'V' : '.'); av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM ) ? 'A' : '.'); av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.'); + av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_EXPORT) ? 'X' : '.'); + av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_READONLY) ? 'R' : '.'); if (opt->help) av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help); @@ -1106,6 +1159,10 @@ void av_opt_set_defaults2(void *s, int mask, int flags) if ((opt->flags & mask) != flags) continue; #endif + + if (opt->flags & AV_OPT_FLAG_READONLY) + continue; + switch (opt->type) { case AV_OPT_TYPE_CONST: /* Nothing to be done here */ @@ -1143,7 +1200,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags) set_string_video_rate(s, opt, opt->default_val.str, dst); break; case AV_OPT_TYPE_PIXEL_FMT: -#if LIBAVUTIL_VERSION_MAJOR < 53 +#if LIBAVUTIL_VERSION_MAJOR < 54 if (class->version && class->version < AV_VERSION_INT(52, 10, 100)) av_opt_set(s, opt->name, opt->default_val.str, 0); else @@ -1151,7 +1208,7 @@ void av_opt_set_defaults2(void *s, int mask, int flags) write_number(s, opt, dst, 1, 1, opt->default_val.i64); break; case AV_OPT_TYPE_SAMPLE_FMT: -#if LIBAVUTIL_VERSION_MAJOR < 53 +#if LIBAVUTIL_VERSION_MAJOR < 54 if (class->version && class->version < AV_VERSION_INT(52, 10, 100)) av_opt_set(s, opt->name, opt->default_val.str, 0); else @@ -1358,14 +1415,17 @@ void av_opt_free(void *obj) av_freep((uint8_t *)obj + o->offset); } -int av_opt_set_dict(void *obj, AVDictionary **options) +int av_opt_set_dict2(void *obj, AVDictionary **options, int search_flags) { AVDictionaryEntry *t = NULL; AVDictionary *tmp = NULL; int ret = 0; + if (!options) + return 0; + while ((t = av_dict_get(*options, "", t, AV_DICT_IGNORE_SUFFIX))) { - ret = av_opt_set(obj, t->key, t->value, 0); + ret = av_opt_set(obj, t->key, t->value, search_flags); if (ret == AVERROR_OPTION_NOT_FOUND) av_dict_set(&tmp, t->key, t->value, 0); else if (ret < 0) { @@ -1379,6 +1439,11 @@ int av_opt_set_dict(void *obj, AVDictionary **options) return ret; } +int av_opt_set_dict(void *obj, AVDictionary **options) +{ + return av_opt_set_dict2(obj, options, 0); +} + const AVOption *av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags) { @@ -1454,6 +1519,7 @@ void *av_opt_ptr(const AVClass *class, void *obj, const char *name) int av_opt_query_ranges(AVOptionRanges **ranges_arg, void *obj, const char *key, int flags) { + int ret; const AVClass *c = *(AVClass**)obj; int (*callback)(AVOptionRanges **, void *obj, const char *key, int flags) = NULL; @@ -1463,7 +1529,13 @@ int av_opt_query_ranges(AVOptionRanges **ranges_arg, void *obj, const char *key, if (!callback) callback = av_opt_query_ranges_default; - return callback(ranges_arg, obj, key, flags); + ret = callback(ranges_arg, obj, key, flags); + if (ret >= 0) { + if (!(flags & AV_OPT_MULTI_COMPONENT_RANGE)) + ret = 1; + (*ranges_arg)->nb_components = ret; + } + return ret; } int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const char *key, int flags) @@ -1484,6 +1556,7 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch ranges->range = range_array; ranges->range[0] = range; ranges->nb_ranges = 1; + ranges->nb_components = 1; range->is_range = 1; range->value_min = field->min; range->value_max = field->max; @@ -1527,7 +1600,7 @@ int av_opt_query_ranges_default(AVOptionRanges **ranges_arg, void *obj, const ch } *ranges_arg = ranges; - return 0; + return 1; fail: av_free(ranges); av_free(range); @@ -1540,10 +1613,15 @@ void av_opt_freep_ranges(AVOptionRanges **rangesp) int i; AVOptionRanges *ranges = *rangesp; - for (i = 0; i < ranges->nb_ranges; i++) { + if (!ranges) + return; + + for (i = 0; i < ranges->nb_ranges * ranges->nb_components; i++) { AVOptionRange *range = ranges->range[i]; - av_freep(&range->str); - av_freep(&ranges->range[i]); + if (range) { + av_freep(&range->str); + av_freep(&ranges->range[i]); + } } av_freep(&ranges->range); av_freep(rangesp); @@ -1584,8 +1662,8 @@ static const AVOption test_options[]= { {"lame", "set lame flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_LAME}, INT_MIN, INT_MAX, 0, "flags" }, {"mu", "set mu flag ", 0, AV_OPT_TYPE_CONST, {.i64 = TEST_FLAG_MU}, INT_MIN, INT_MAX, 0, "flags" }, {"size", "set size", OFFSET(w), AV_OPT_TYPE_IMAGE_SIZE,{0}, 0, 0 }, -{"pix_fmt", "set pixfmt", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, {.i64 = AV_PIX_FMT_NONE}, -1, AV_PIX_FMT_NB-1}, -{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_NONE}, -1, AV_SAMPLE_FMT_NB-1}, +{"pix_fmt", "set pixfmt", OFFSET(pix_fmt), AV_OPT_TYPE_PIXEL_FMT, {.i64 = AV_PIX_FMT_NONE}, -1, INT_MAX}, +{"sample_fmt", "set samplefmt", OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, {.i64 = AV_SAMPLE_FMT_NONE}, -1, INT_MAX}, {"video_rate", "set videorate", OFFSET(video_rate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0 }, {"duration", "set duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = 0}, 0, INT64_MAX}, {"color", "set color", OFFSET(color), AV_OPT_TYPE_COLOR, {.str = "pink"}, 0, 0}, diff --git a/chromium/third_party/ffmpeg/libavutil/opt.h b/chromium/third_party/ffmpeg/libavutil/opt.h index 14faa6e066e..1e1dd69b30e 100644 --- a/chromium/third_party/ffmpeg/libavutil/opt.h +++ b/chromium/third_party/ffmpeg/libavutil/opt.h @@ -282,10 +282,21 @@ typedef struct AVOption { int flags; #define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding #define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding +#if FF_API_OPT_TYPE_METADATA #define AV_OPT_FLAG_METADATA 4 ///< some data extracted or inserted into the file like title, comment, ... +#endif #define AV_OPT_FLAG_AUDIO_PARAM 8 #define AV_OPT_FLAG_VIDEO_PARAM 16 #define AV_OPT_FLAG_SUBTITLE_PARAM 32 +/** + * The option is inteded for exporting values to the caller. + */ +#define AV_OPT_FLAG_EXPORT 64 +/** + * The option may not be set through the AVOptions API, only read. + * This flag only makes sense when AV_OPT_FLAG_EXPORT is also set. + */ +#define AV_OPT_FLAG_READONLY 128 #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering //FIXME think about enc-audio, ... style flags @@ -302,17 +313,67 @@ typedef struct AVOption { */ typedef struct AVOptionRange { const char *str; - double value_min, value_max; ///< For string ranges this represents the min/max length, for dimensions this represents the min/max pixel count - double component_min, component_max; ///< For string this represents the unicode range for chars, 0-127 limits to ASCII - int is_range; ///< if set to 1 the struct encodes a range, if set to 0 a single value + /** + * Value range. + * For string ranges this represents the min/max length. + * For dimensions this represents the min/max pixel count or width/height in multi-component case. + */ + double value_min, value_max; + /** + * Value's component range. + * For string this represents the unicode range for chars, 0-127 limits to ASCII. + */ + double component_min, component_max; + /** + * Range flag. + * If set to 1 the struct encodes a range, if set to 0 a single value. + */ + int is_range; } AVOptionRange; /** - * List of AVOptionRange structs + * List of AVOptionRange structs. */ typedef struct AVOptionRanges { + /** + * Array of option ranges. + * + * Most of option types use just one component. + * Following describes multi-component option types: + * + * AV_OPT_TYPE_IMAGE_SIZE: + * component index 0: range of pixel count (width * height). + * component index 1: range of width. + * component index 2: range of height. + * + * @note To obtain multi-component version of this structure, user must + * provide AV_OPT_MULTI_COMPONENT_RANGE to av_opt_query_ranges or + * av_opt_query_ranges_default function. + * + * Multi-component range can be read as in following example: + * + * @code + * int range_index, component_index; + * AVOptionRanges *ranges; + * AVOptionRange *range[3]; //may require more than 3 in the future. + * av_opt_query_ranges(&ranges, obj, key, AV_OPT_MULTI_COMPONENT_RANGE); + * for (range_index = 0; range_index < ranges->nb_ranges; range_index++) { + * for (component_index = 0; component_index < ranges->nb_components; component_index++) + * range[component_index] = ranges->range[ranges->nb_ranges * component_index + range_index]; + * //do something with range here. + * } + * av_opt_freep_ranges(&ranges); + * @endcode + */ AVOptionRange **range; + /** + * Number of ranges per component. + */ int nb_ranges; + /** + * Number of componentes. + */ + int nb_components; } AVOptionRanges; @@ -480,6 +541,24 @@ int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name) */ int av_opt_set_dict(void *obj, struct AVDictionary **options); + +/** + * Set all the options from a given dictionary on an object. + * + * @param obj a struct whose first element is a pointer to AVClass + * @param options options to process. This dictionary will be freed and replaced + * by a new one containing all options not found in obj. + * Of course this new dictionary needs to be freed by caller + * with av_dict_free(). + * @param search_flags A combination of AV_OPT_SEARCH_*. + * + * @return 0 on success, a negative AVERROR if some option was found in obj, + * but could not be set. + * + * @see av_dict_copy() + */ +int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags); + /** * Extract a key-value pair from the beginning of a string. * @@ -548,6 +627,13 @@ int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational #define AV_OPT_SEARCH_FAKE_OBJ 0x0002 /** + * Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than + * one component for certain option types. + * @see AVOptionRanges for details. + */ +#define AV_OPT_MULTI_COMPONENT_RANGE 0x1000 + +/** * Look for an option in an object. Consider only options which * have all the specified flags set. * @@ -728,10 +814,11 @@ void av_opt_freep_ranges(AVOptionRanges **ranges); * * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored * AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance + * AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges * * The result must be freed with av_opt_freep_ranges. * - * @return >= 0 on success, a negative errro code otherwise + * @return number of compontents returned on success, a negative errro code otherwise */ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags); @@ -743,10 +830,11 @@ int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags * * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored * AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance + * AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges * * The result must be freed with av_opt_free_ranges. * - * @return >= 0 on success, a negative errro code otherwise + * @return number of compontents returned on success, a negative errro code otherwise */ int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags); diff --git a/chromium/third_party/ffmpeg/libavutil/parseutils.c b/chromium/third_party/ffmpeg/libavutil/parseutils.c index e793e2d4c6a..ba4b4e1b722 100644 --- a/chromium/third_party/ffmpeg/libavutil/parseutils.c +++ b/chromium/third_party/ffmpeg/libavutil/parseutils.c @@ -613,12 +613,14 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration) dt.tm_hour = 0; } if (!q) { + char *o; /* parse timestr as S+ */ - dt.tm_sec = strtol(p, (void *)&q, 10); - if (q == p) /* the parsing didn't succeed */ + dt.tm_sec = strtol(p, &o, 10); + if (o == p) /* the parsing didn't succeed */ return AVERROR(EINVAL); dt.tm_min = 0; dt.tm_hour = 0; + q = o; } } diff --git a/chromium/third_party/ffmpeg/libavutil/pca.c b/chromium/third_party/ffmpeg/libavutil/pca.c index 311b6bc9cb4..26d5bbb1570 100644 --- a/chromium/third_party/ffmpeg/libavutil/pca.c +++ b/chromium/third_party/ffmpeg/libavutil/pca.c @@ -42,7 +42,7 @@ PCA *ff_pca_init(int n){ pca= av_mallocz(sizeof(*pca)); pca->n= n; - pca->z = av_malloc(sizeof(*pca->z) * n); + pca->z = av_malloc_array(n, sizeof(*pca->z)); pca->count=0; pca->covariance= av_calloc(n*n, sizeof(double)); pca->mean= av_calloc(n, sizeof(double)); diff --git a/chromium/third_party/ffmpeg/libavutil/pixdesc.c b/chromium/third_party/ffmpeg/libavutil/pixdesc.c index 0cb2f34f57e..f00907dc240 100644 --- a/chromium/third_party/ffmpeg/libavutil/pixdesc.c +++ b/chromium/third_party/ffmpeg/libavutil/pixdesc.c @@ -154,6 +154,17 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { { 0, 3, 4, 0, 7 }, /* V */ }, }, + [AV_PIX_FMT_YVYU422] = { + .name = "yvyu422", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 1, 1, 0, 7 }, /* Y */ + { 0, 3, 2, 0, 7 }, /* V */ + { 0, 3, 4, 0, 7 }, /* U */ + }, + }, [AV_PIX_FMT_RGB24] = { .name = "rgb24", .nb_components = 3, @@ -324,6 +335,12 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .flags = AV_PIX_FMT_FLAG_HWACCEL, }, #endif /* FF_API_XVMC */ +#if !FF_API_XVMC + [AV_PIX_FMT_XVMC] = { + .name = "xvmc", + .flags = AV_PIX_FMT_FLAG_HWACCEL, + }, +#endif /* !FF_API_XVMC */ [AV_PIX_FMT_UYVY422] = { .name = "uyvy422", .nb_components = 3, @@ -922,22 +939,22 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, [AV_PIX_FMT_RGBA64BE] = { .name = "rgba64be", - .nb_components= 4, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { { 0, 7, 1, 0, 15 }, /* R */ { 0, 7, 3, 0, 15 }, /* G */ { 0, 7, 5, 0, 15 }, /* B */ { 0, 7, 7, 0, 15 }, /* A */ }, - .flags = AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_ALPHA, + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_ALPHA, }, [AV_PIX_FMT_RGBA64LE] = { .name = "rgba64le", - .nb_components= 4, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { { 0, 7, 1, 0, 15 }, /* R */ { 0, 7, 3, 0, 15 }, /* G */ @@ -1044,9 +1061,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, [AV_PIX_FMT_BGRA64BE] = { .name = "bgra64be", - .nb_components= 4, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { { 0, 7, 5, 0, 15 }, /* R */ { 0, 7, 3, 0, 15 }, /* G */ @@ -1057,9 +1074,9 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, [AV_PIX_FMT_BGRA64LE] = { .name = "bgra64le", - .nb_components= 4, - .log2_chroma_w= 0, - .log2_chroma_h= 0, + .nb_components = 4, + .log2_chroma_w = 0, + .log2_chroma_h = 0, .comp = { { 0, 7, 5, 0, 15 }, /* R */ { 0, 7, 3, 0, 15 }, /* G */ @@ -1764,50 +1781,62 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { [AV_PIX_FMT_BAYER_BGGR8] = { .name = "bayer_bggr8", BAYER8_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_BGGR16LE] = { .name = "bayer_bggr16le", BAYER16_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_BGGR16BE] = { .name = "bayer_bggr16be", BAYER16_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_RGGB8] = { .name = "bayer_rggb8", BAYER8_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_RGGB16LE] = { .name = "bayer_rggb16le", BAYER16_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_RGGB16BE] = { .name = "bayer_rggb16be", BAYER16_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_GBRG8] = { .name = "bayer_gbrg8", BAYER8_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_GBRG16LE] = { .name = "bayer_gbrg16le", BAYER16_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_GBRG16BE] = { .name = "bayer_gbrg16be", BAYER16_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_GRBG8] = { .name = "bayer_grbg8", BAYER8_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_GRBG16LE] = { .name = "bayer_grbg16le", BAYER16_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_BAYER_GRBG16BE] = { .name = "bayer_grbg16be", BAYER16_DESC_COMMON + .flags = AV_PIX_FMT_FLAG_BE | AV_PIX_FMT_FLAG_RGB, }, [AV_PIX_FMT_NV16] = { .name = "nv16", @@ -1845,6 +1874,10 @@ const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { }, .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, }, + [AV_PIX_FMT_VDA] = { + .name = "vda", + .flags = AV_PIX_FMT_FLAG_HWACCEL, + }, }; FF_DISABLE_DEPRECATION_WARNINGS @@ -2053,3 +2086,226 @@ enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt) return get_pix_fmt_internal(name); } + +#define FF_COLOR_NA -1 +#define FF_COLOR_RGB 0 /**< RGB color space */ +#define FF_COLOR_GRAY 1 /**< gray color space */ +#define FF_COLOR_YUV 2 /**< YUV color space. 16 <= Y <= 235, 16 <= U, V <= 240 */ +#define FF_COLOR_YUV_JPEG 3 /**< YUV color space. 0 <= Y <= 255, 0 <= U, V <= 255 */ + +#define pixdesc_has_alpha(pixdesc) \ + ((pixdesc)->nb_components == 2 || (pixdesc)->nb_components == 4 || (pixdesc)->flags & AV_PIX_FMT_FLAG_PAL) + + +static int get_color_type(const AVPixFmtDescriptor *desc) { + if (desc->flags & AV_PIX_FMT_FLAG_PAL) + return FF_COLOR_RGB; + + if(desc->nb_components == 1 || desc->nb_components == 2) + return FF_COLOR_GRAY; + + if(desc->name && !strncmp(desc->name, "yuvj", 4)) + return FF_COLOR_YUV_JPEG; + + if(desc->flags & AV_PIX_FMT_FLAG_RGB) + return FF_COLOR_RGB; + + if(desc->nb_components == 0) + return FF_COLOR_NA; + + return FF_COLOR_YUV; +} + +static int get_pix_fmt_depth(int *min, int *max, enum AVPixelFormat pix_fmt) +{ + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); + int i; + + if (!desc || !desc->nb_components) { + *min = *max = 0; + return AVERROR(EINVAL); + } + + *min = INT_MAX, *max = -INT_MAX; + for (i = 0; i < desc->nb_components; i++) { + *min = FFMIN(desc->comp[i].depth_minus1+1, *min); + *max = FFMAX(desc->comp[i].depth_minus1+1, *max); + } + return 0; +} + +static int get_pix_fmt_score(enum AVPixelFormat dst_pix_fmt, + enum AVPixelFormat src_pix_fmt, + unsigned *lossp, unsigned consider) +{ + const AVPixFmtDescriptor *src_desc = av_pix_fmt_desc_get(src_pix_fmt); + const AVPixFmtDescriptor *dst_desc = av_pix_fmt_desc_get(dst_pix_fmt); + int src_color, dst_color; + int src_min_depth, src_max_depth, dst_min_depth, dst_max_depth; + int ret, loss, i, nb_components; + int score = INT_MAX - 1; + + if (dst_pix_fmt >= AV_PIX_FMT_NB || dst_pix_fmt <= AV_PIX_FMT_NONE) + return ~0; + + /* compute loss */ + *lossp = loss = 0; + + if (dst_pix_fmt == src_pix_fmt) + return INT_MAX; + + if ((ret = get_pix_fmt_depth(&src_min_depth, &src_max_depth, src_pix_fmt)) < 0) + return ret; + if ((ret = get_pix_fmt_depth(&dst_min_depth, &dst_max_depth, dst_pix_fmt)) < 0) + return ret; + + src_color = get_color_type(src_desc); + dst_color = get_color_type(dst_desc); + if (dst_pix_fmt == AV_PIX_FMT_PAL8) + nb_components = FFMIN(src_desc->nb_components, 4); + else + nb_components = FFMIN(src_desc->nb_components, dst_desc->nb_components); + + for (i = 0; i < nb_components; i++) { + int depth_minus1 = (dst_pix_fmt == AV_PIX_FMT_PAL8) ? 7/nb_components : dst_desc->comp[i].depth_minus1; + if (src_desc->comp[i].depth_minus1 > depth_minus1 && (consider & FF_LOSS_DEPTH)) { + loss |= FF_LOSS_DEPTH; + score -= 65536 >> depth_minus1; + } + } + + if (consider & FF_LOSS_RESOLUTION) { + if (dst_desc->log2_chroma_w > src_desc->log2_chroma_w) { + loss |= FF_LOSS_RESOLUTION; + score -= 256 << dst_desc->log2_chroma_w; + } + if (dst_desc->log2_chroma_h > src_desc->log2_chroma_h) { + loss |= FF_LOSS_RESOLUTION; + score -= 256 << dst_desc->log2_chroma_h; + } + // don't favor 422 over 420 if downsampling is needed, because 420 has much better support on the decoder side + if (dst_desc->log2_chroma_w == 1 && src_desc->log2_chroma_w == 0 && + dst_desc->log2_chroma_h == 1 && src_desc->log2_chroma_h == 0 ) { + score += 512; + } + } + + if(consider & FF_LOSS_COLORSPACE) + switch(dst_color) { + case FF_COLOR_RGB: + if (src_color != FF_COLOR_RGB && + src_color != FF_COLOR_GRAY) + loss |= FF_LOSS_COLORSPACE; + break; + case FF_COLOR_GRAY: + if (src_color != FF_COLOR_GRAY) + loss |= FF_LOSS_COLORSPACE; + break; + case FF_COLOR_YUV: + if (src_color != FF_COLOR_YUV) + loss |= FF_LOSS_COLORSPACE; + break; + case FF_COLOR_YUV_JPEG: + if (src_color != FF_COLOR_YUV_JPEG && + src_color != FF_COLOR_YUV && + src_color != FF_COLOR_GRAY) + loss |= FF_LOSS_COLORSPACE; + break; + default: + /* fail safe test */ + if (src_color != dst_color) + loss |= FF_LOSS_COLORSPACE; + break; + } + if(loss & FF_LOSS_COLORSPACE) + score -= (nb_components * 65536) >> FFMIN(dst_desc->comp[0].depth_minus1, src_desc->comp[0].depth_minus1); + + if (dst_color == FF_COLOR_GRAY && + src_color != FF_COLOR_GRAY && (consider & FF_LOSS_CHROMA)) { + loss |= FF_LOSS_CHROMA; + score -= 2 * 65536; + } + if (!pixdesc_has_alpha(dst_desc) && (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))) { + loss |= FF_LOSS_ALPHA; + score -= 65536; + } + if (dst_pix_fmt == AV_PIX_FMT_PAL8 && (consider & FF_LOSS_COLORQUANT) && + (src_pix_fmt != AV_PIX_FMT_PAL8 && (src_color != FF_COLOR_GRAY || (pixdesc_has_alpha(src_desc) && (consider & FF_LOSS_ALPHA))))) { + loss |= FF_LOSS_COLORQUANT; + score -= 65536; + } + + *lossp = loss; + return score; +} + +int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, + enum AVPixelFormat src_pix_fmt, + int has_alpha) +{ + int loss; + int ret = get_pix_fmt_score(dst_pix_fmt, src_pix_fmt, &loss, has_alpha ? ~0 : ~FF_LOSS_ALPHA); + if (ret < 0) + return ret; + return loss; +} + +enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, + enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr) +{ + enum AVPixelFormat dst_pix_fmt; + int loss1, loss2, loss_mask; + const AVPixFmtDescriptor *desc1 = av_pix_fmt_desc_get(dst_pix_fmt1); + const AVPixFmtDescriptor *desc2 = av_pix_fmt_desc_get(dst_pix_fmt2); + int score1, score2; + + loss_mask= loss_ptr?~*loss_ptr:~0; /* use loss mask if provided */ + if(!has_alpha) + loss_mask &= ~FF_LOSS_ALPHA; + + dst_pix_fmt = AV_PIX_FMT_NONE; + score1 = get_pix_fmt_score(dst_pix_fmt1, src_pix_fmt, &loss1, loss_mask); + score2 = get_pix_fmt_score(dst_pix_fmt2, src_pix_fmt, &loss2, loss_mask); + + if (score1 == score2) { + if(av_get_padded_bits_per_pixel(desc2) != av_get_padded_bits_per_pixel(desc1)) { + dst_pix_fmt = av_get_padded_bits_per_pixel(desc2) < av_get_padded_bits_per_pixel(desc1) ? dst_pix_fmt2 : dst_pix_fmt1; + } else { + dst_pix_fmt = desc2->nb_components < desc1->nb_components ? dst_pix_fmt2 : dst_pix_fmt1; + } + } else { + dst_pix_fmt = score1 < score2 ? dst_pix_fmt2 : dst_pix_fmt1; + } + + if (loss_ptr) + *loss_ptr = av_get_pix_fmt_loss(dst_pix_fmt, src_pix_fmt, has_alpha); + return dst_pix_fmt; +} + +#ifdef TEST + +int main(void){ + int i; + int err=0; + int skip = 0; + + for (i=0; i<AV_PIX_FMT_NB*2; i++) { + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(i); + if(!desc || !desc->name) { + skip ++; + continue; + } + if (skip) { + av_log(NULL, AV_LOG_INFO, "%3d unused pixel format values\n", skip); + skip = 0; + } + av_log(NULL, AV_LOG_INFO, "pix fmt %s avg_bpp:%d colortype:%d\n", desc->name, av_get_padded_bits_per_pixel(desc), get_color_type(desc)); + if ((!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) != (desc->nb_components != 2 && desc->nb_components != 4)) { + av_log(NULL, AV_LOG_ERROR, "Alpha flag mismatch\n"); + err = 1; + } + } + return err; +} + +#endif diff --git a/chromium/third_party/ffmpeg/libavutil/pixdesc.h b/chromium/third_party/ffmpeg/libavutil/pixdesc.h index e88bf9b92ac..1d2ead6cb99 100644 --- a/chromium/third_party/ffmpeg/libavutil/pixdesc.h +++ b/chromium/third_party/ffmpeg/libavutil/pixdesc.h @@ -255,7 +255,7 @@ enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc); * Utility function to access log2_chroma_w log2_chroma_h from * the pixel format AVPixFmtDescriptor. * - * See avcodec_get_chroma_sub_sample() for a function that asserts a + * See av_get_chroma_sub_sample() for a function that asserts a * valid pixel format instead of returning an error code. * Its recommanded that you use avcodec_get_chroma_sub_sample unless * you do check the return code! @@ -287,5 +287,53 @@ void ff_check_pixfmt_descriptors(void); */ enum AVPixelFormat av_pix_fmt_swap_endianness(enum AVPixelFormat pix_fmt); +#define FF_LOSS_RESOLUTION 0x0001 /**< loss due to resolution change */ +#define FF_LOSS_DEPTH 0x0002 /**< loss due to color depth change */ +#define FF_LOSS_COLORSPACE 0x0004 /**< loss due to color space conversion */ +#define FF_LOSS_ALPHA 0x0008 /**< loss of alpha bits */ +#define FF_LOSS_COLORQUANT 0x0010 /**< loss due to color quantization */ +#define FF_LOSS_CHROMA 0x0020 /**< loss of chroma (e.g. RGB to gray conversion) */ +/** + * Compute what kind of losses will occur when converting from one specific + * pixel format to another. + * When converting from one pixel format to another, information loss may occur. + * For example, when converting from RGB24 to GRAY, the color information will + * be lost. Similarly, other losses occur when converting from some formats to + * other formats. These losses can involve loss of chroma, but also loss of + * resolution, loss of color depth, loss due to the color space conversion, loss + * of the alpha bits or loss due to color quantization. + * av_get_fix_fmt_loss() informs you about the various types of losses + * which will occur when converting from one pixel format to another. + * + * @param[in] dst_pix_fmt destination pixel format + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @return Combination of flags informing you what kind of losses will occur + * (maximum loss for an invalid dst_pix_fmt). + */ +int av_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, + enum AVPixelFormat src_pix_fmt, + int has_alpha); + +/** + * Compute what kind of losses will occur when converting from one specific + * pixel format to another. + * When converting from one pixel format to another, information loss may occur. + * For example, when converting from RGB24 to GRAY, the color information will + * be lost. Similarly, other losses occur when converting from some formats to + * other formats. These losses can involve loss of chroma, but also loss of + * resolution, loss of color depth, loss due to the color space conversion, loss + * of the alpha bits or loss due to color quantization. + * av_get_fix_fmt_loss() informs you about the various types of losses + * which will occur when converting from one pixel format to another. + * + * @param[in] dst_pix_fmt destination pixel format + * @param[in] src_pix_fmt source pixel format + * @param[in] has_alpha Whether the source pixel format alpha channel is used. + * @return Combination of flags informing you what kind of losses will occur + * (maximum loss for an invalid dst_pix_fmt). + */ +enum AVPixelFormat av_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, + enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); #endif /* AVUTIL_PIXDESC_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/pixfmt.h b/chromium/third_party/ffmpeg/libavutil/pixfmt.h index 3d32d3eec97..98987a5cd69 100644 --- a/chromium/third_party/ffmpeg/libavutil/pixfmt.h +++ b/chromium/third_party/ffmpeg/libavutil/pixfmt.h @@ -83,6 +83,7 @@ enum AVPixelFormat { #if FF_API_XVMC AV_PIX_FMT_XVMC_MPEG2_MC,///< XVideo Motion Acceleration via common packet passing AV_PIX_FMT_XVMC_MPEG2_IDCT, +#define AV_PIX_FMT_XVMC AV_PIX_FMT_XVMC_MPEG2_IDCT #endif /* FF_API_XVMC */ AV_PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 AV_PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 @@ -216,6 +217,21 @@ enum AVPixelFormat { AV_PIX_FMT_NV20LE, ///< interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian AV_PIX_FMT_NV20BE, ///< interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian + /** + * duplicated pixel formats for compatibility with libav. + * FFmpeg supports these formats since Sat Sep 24 06:01:45 2011 +0200 (commits 9569a3c9f41387a8c7d1ce97d8693520477a66c3) + * also see Fri Nov 25 01:38:21 2011 +0100 92afb431621c79155fcb7171d26f137eb1bee028 + * Libav added them Sun Mar 16 23:05:47 2014 +0100 with incompatible values (commit 1481d24c3a0abf81e1d7a514547bd5305232be30) + */ + AV_PIX_FMT_RGBA64BE_LIBAV, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian + AV_PIX_FMT_RGBA64LE_LIBAV, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian + AV_PIX_FMT_BGRA64BE_LIBAV, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian + AV_PIX_FMT_BGRA64LE_LIBAV, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian + + AV_PIX_FMT_YVYU422, ///< packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb + + AV_PIX_FMT_VDA, ///< HW acceleration through VDA, data[3] contains a CVPixelBufferRef + #ifndef AV_PIX_FMT_ABI_GIT_MASTER AV_PIX_FMT_RGBA64BE=0x123, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian AV_PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian @@ -262,6 +278,9 @@ enum AVPixelFormat { AV_PIX_FMT_BAYER_GBRG16BE, ///< bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian */ AV_PIX_FMT_BAYER_GRBG16LE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian */ AV_PIX_FMT_BAYER_GRBG16BE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian */ +#if !FF_API_XVMC + AV_PIX_FMT_XVMC,///< XVideo Motion Acceleration via common packet passing +#endif /* !FF_API_XVMC */ AV_PIX_FMT_NB, ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions @@ -273,6 +292,10 @@ enum AVPixelFormat { #if AV_HAVE_INCOMPATIBLE_LIBAV_ABI #define AV_PIX_FMT_YUVA422P AV_PIX_FMT_YUVA422P_LIBAV #define AV_PIX_FMT_YUVA444P AV_PIX_FMT_YUVA444P_LIBAV +#define AV_PIX_FMT_RGBA64BE AV_PIX_FMT_RGBA64BE_LIBAV +#define AV_PIX_FMT_RGBA64LE AV_PIX_FMT_RGBA64LE_LIBAV +#define AV_PIX_FMT_BGRA64BE AV_PIX_FMT_BGRA64BE_LIBAV +#define AV_PIX_FMT_BGRA64LE AV_PIX_FMT_BGRA64LE_LIBAV #endif @@ -297,10 +320,12 @@ enum AVPixelFormat { #define AV_PIX_FMT_RGB565 AV_PIX_FMT_NE(RGB565BE, RGB565LE) #define AV_PIX_FMT_RGB555 AV_PIX_FMT_NE(RGB555BE, RGB555LE) #define AV_PIX_FMT_RGB444 AV_PIX_FMT_NE(RGB444BE, RGB444LE) +#define AV_PIX_FMT_RGBA64 AV_PIX_FMT_NE(RGBA64BE, RGBA64LE) #define AV_PIX_FMT_BGR48 AV_PIX_FMT_NE(BGR48BE, BGR48LE) #define AV_PIX_FMT_BGR565 AV_PIX_FMT_NE(BGR565BE, BGR565LE) #define AV_PIX_FMT_BGR555 AV_PIX_FMT_NE(BGR555BE, BGR555LE) #define AV_PIX_FMT_BGR444 AV_PIX_FMT_NE(BGR444BE, BGR444LE) +#define AV_PIX_FMT_BGRA64 AV_PIX_FMT_NE(BGRA64BE, BGRA64LE) #define AV_PIX_FMT_YUV420P9 AV_PIX_FMT_NE(YUV420P9BE , YUV420P9LE) #define AV_PIX_FMT_YUV422P9 AV_PIX_FMT_NE(YUV422P9BE , YUV422P9LE) @@ -318,8 +343,6 @@ enum AVPixelFormat { #define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE) #define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE) -#define AV_PIX_FMT_RGBA64 AV_PIX_FMT_NE(RGBA64BE, RGBA64LE) -#define AV_PIX_FMT_BGRA64 AV_PIX_FMT_NE(BGRA64BE, BGRA64LE) #define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE , GBRP9LE) #define AV_PIX_FMT_GBRP10 AV_PIX_FMT_NE(GBRP10BE, GBRP10LE) #define AV_PIX_FMT_GBRP12 AV_PIX_FMT_NE(GBRP12BE, GBRP12LE) @@ -346,6 +369,7 @@ enum AVPixelFormat { #define AV_PIX_FMT_XYZ12 AV_PIX_FMT_NE(XYZ12BE, XYZ12LE) #define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE) + #if FF_API_PIX_FMT #define PixelFormat AVPixelFormat diff --git a/chromium/third_party/ffmpeg/libavutil/random_seed.c b/chromium/third_party/ffmpeg/libavutil/random_seed.c index aa8902472ea..e3ffaff014e 100644 --- a/chromium/third_party/ffmpeg/libavutil/random_seed.c +++ b/chromium/third_party/ffmpeg/libavutil/random_seed.c @@ -33,10 +33,10 @@ #include <string.h> #include "avassert.h" #include "internal.h" +#include "intreadwrite.h" #include "timer.h" #include "random_seed.h" #include "sha.h" -#include "intreadwrite.h" #ifndef TEST #define TEST 0 @@ -65,7 +65,7 @@ static uint32_t get_generic_seed(void) struct AVSHA *sha = (void*)tmp; clock_t last_t = 0; static uint64_t i = 0; - static uint32_t buffer[512] = {0}; + static uint32_t buffer[512] = { 0 }; unsigned char digest[20]; uint64_t last_i = i; @@ -84,11 +84,11 @@ static uint32_t get_generic_seed(void) for (;;) { clock_t t = clock(); - if(last_t == t){ - buffer[i&511]++; - }else{ - buffer[++i&511]+= (t-last_t) % 3294638521U; - if(last_i && i-last_i > 4 || i-last_i > 64 || TEST && i-last_i > 8) + if (last_t == t) { + buffer[i & 511]++; + } else { + buffer[++i & 511] += (t - last_t) % 3294638521U; + if (last_i && i - last_i > 4 || i - last_i > 64 || TEST && i - last_i > 8) break; } last_t = t; @@ -98,9 +98,9 @@ static uint32_t get_generic_seed(void) buffer[0] = buffer[1] = 0; av_sha_init(sha, 160); - av_sha_update(sha, (uint8_t*)buffer, sizeof(buffer)); + av_sha_update(sha, (const uint8_t *)buffer, sizeof(buffer)); av_sha_final(sha, digest); - return AV_RB32(digest) + AV_RB32(digest+16); + return AV_RB32(digest) + AV_RB32(digest + 16); } uint32_t av_get_random_seed(void) diff --git a/chromium/third_party/ffmpeg/libavutil/rational.c b/chromium/third_party/ffmpeg/libavutil/rational.c index ec2f2e53866..55a8dd58972 100644 --- a/chromium/third_party/ffmpeg/libavutil/rational.c +++ b/chromium/third_party/ffmpeg/libavutil/rational.c @@ -171,6 +171,36 @@ int main(void) } } } + + for (a.num = 1; a.num <= 10; a.num++) { + for (a.den = 1; a.den <= 10; a.den++) { + if (av_gcd(a.num, a.den) > 1) + continue; + for (b.num = 1; b.num <= 10; b.num++) { + for (b.den = 1; b.den <= 10; b.den++) { + int start; + if (av_gcd(b.num, b.den) > 1) + continue; + if (av_cmp_q(b, a) < 0) + continue; + for (start = 0; start < 10 ; start++) { + int acc= start; + int i; + + for (i = 0; i<100; i++) { + int exact = start + av_rescale_q(i+1, b, a); + acc = av_add_stable(a, acc, b, 1); + if (FFABS(acc - exact) > 2) { + av_log(NULL, AV_LOG_ERROR, "%d/%d %d/%d, %d %d\n", a.num, + a.den, b.num, b.den, acc, exact); + return 1; + } + } + } + } + } + } + } return 0; } #endif diff --git a/chromium/third_party/ffmpeg/libavutil/rational.h b/chromium/third_party/ffmpeg/libavutil/rational.h index b9800ee3600..7439701db23 100644 --- a/chromium/third_party/ffmpeg/libavutil/rational.h +++ b/chromium/third_party/ffmpeg/libavutil/rational.h @@ -46,6 +46,17 @@ typedef struct AVRational{ } AVRational; /** + * Create a rational. + * Useful for compilers that do not support compound literals. + * @note The return value is not reduced. + */ +static inline AVRational av_make_q(int num, int den) +{ + AVRational r = { num, den }; + return r; +} + +/** * Compare two rationals. * @param a first rational * @param b second rational diff --git a/chromium/third_party/ffmpeg/libavutil/replaygain.h b/chromium/third_party/ffmpeg/libavutil/replaygain.h new file mode 100644 index 00000000000..5c03e1993d8 --- /dev/null +++ b/chromium/third_party/ffmpeg/libavutil/replaygain.h @@ -0,0 +1,51 @@ +/* + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_REPLAYGAIN_H +#define AVUTIL_REPLAYGAIN_H + +#include <stdint.h> + +/** + * ReplayGain information (see + * http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification). + * The size of this struct is a part of the public ABI. + */ +typedef struct AVReplayGain { + /** + * Track replay gain in microbels (divide by 100000 to get the value in dB). + * Should be set to INT32_MIN when unknown. + */ + int32_t track_gain; + /** + * Peak track amplitude, with 100000 representing full scale (but values + * may overflow). 0 when unknown. + */ + uint32_t track_peak; + /** + * Same as track_gain, but for the whole album. + */ + int32_t album_gain; + /** + * Same as track_peak, but for the whole album, + */ + uint32_t album_peak; +} AVReplayGain; + +#endif /* AVUTIL_REPLAYGAIN_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/samplefmt.c b/chromium/third_party/ffmpeg/libavutil/samplefmt.c index 08ecc834678..a1986980f05 100644 --- a/chromium/third_party/ffmpeg/libavutil/samplefmt.c +++ b/chromium/third_party/ffmpeg/libavutil/samplefmt.c @@ -135,6 +135,8 @@ int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, /* auto-select alignment if not specified */ if (!align) { + if (nb_samples > INT_MAX - 31) + return AVERROR(EINVAL); align = 1; nb_samples = FFALIGN(nb_samples, 32); } diff --git a/chromium/third_party/ffmpeg/libavutil/stereo3d.h b/chromium/third_party/ffmpeg/libavutil/stereo3d.h index b384ad49afb..8829da9ff44 100644 --- a/chromium/third_party/ffmpeg/libavutil/stereo3d.h +++ b/chromium/third_party/ffmpeg/libavutil/stereo3d.h @@ -140,7 +140,7 @@ AVStereo3D *av_stereo3d_alloc(void); /** * Allocate a complete AVFrameSideData and add it to the frame. * - * @param The frame on which the side data is added to. + * @param frame The frame which side data is added to. * * @return The AVStereo3D structure to be filled by caller. */ diff --git a/chromium/third_party/ffmpeg/libavutil/timer.h b/chromium/third_party/ffmpeg/libavutil/timer.h index 3e242f3463c..3fff77ff1c6 100644 --- a/chromium/third_party/ffmpeg/libavutil/timer.h +++ b/chromium/third_party/ffmpeg/libavutil/timer.h @@ -32,6 +32,12 @@ #include "config.h" +#if HAVE_MACH_MACH_TIME_H +#include <mach/mach_time.h> +#endif + +#include "log.h" + #if ARCH_ARM # include "arm/timer.h" #elif ARCH_BFIN @@ -42,8 +48,16 @@ # include "x86/timer.h" #endif -#if !defined(AV_READ_TIME) && HAVE_GETHRTIME -# define AV_READ_TIME gethrtime +#if !defined(AV_READ_TIME) +# if HAVE_GETHRTIME +# define AV_READ_TIME gethrtime +# elif HAVE_MACH_ABSOLUTE_TIME +# define AV_READ_TIME mach_absolute_time +# endif +#endif + +#ifndef FF_TIMER_UNITS +# define FF_TIMER_UNITS "UNITS" #endif #ifdef AV_READ_TIME @@ -66,7 +80,7 @@ tskip_count++; \ if (((tcount + tskip_count) & (tcount + tskip_count - 1)) == 0) { \ av_log(NULL, AV_LOG_ERROR, \ - "%"PRIu64" decicycles in %s, %d runs, %d skips\n", \ + "%"PRIu64" " FF_TIMER_UNITS " in %s, %d runs, %d skips\n", \ tsum * 10 / tcount, id, tcount, tskip_count); \ } \ } diff --git a/chromium/third_party/ffmpeg/libavutil/timestamp.h b/chromium/third_party/ffmpeg/libavutil/timestamp.h index f63a08c579c..f010a7ee38f 100644 --- a/chromium/third_party/ffmpeg/libavutil/timestamp.h +++ b/chromium/third_party/ffmpeg/libavutil/timestamp.h @@ -26,6 +26,10 @@ #include "common.h" +#if defined(__cplusplus) && !defined(__STDC_FORMAT_MACROS) && !defined(PRId64) +#error missing -D__STDC_FORMAT_MACROS / #define __STDC_FORMAT_MACROS +#endif + #define AV_TS_MAX_STRING_SIZE 32 /** diff --git a/chromium/third_party/ffmpeg/libavutil/utils.c b/chromium/third_party/ffmpeg/libavutil/utils.c index 4c82503d9c6..6c9b493a8f9 100644 --- a/chromium/third_party/ffmpeg/libavutil/utils.c +++ b/chromium/third_party/ffmpeg/libavutil/utils.c @@ -113,3 +113,8 @@ unsigned av_int_list_length_for_size(unsigned elsize, } return i; } + +AVRational av_get_time_base_q(void) +{ + return (AVRational){1, AV_TIME_BASE}; +} diff --git a/chromium/third_party/ffmpeg/libavutil/version.h b/chromium/third_party/ffmpeg/libavutil/version.h index 4eff48cb230..71407053192 100644 --- a/chromium/third_party/ffmpeg/libavutil/version.h +++ b/chromium/third_party/ffmpeg/libavutil/version.h @@ -21,25 +21,7 @@ #ifndef AVUTIL_VERSION_H #define AVUTIL_VERSION_H -/** - * @defgroup preproc_misc Preprocessor String Macros - * - * String manipulation macros - * - * @{ - */ - -#define AV_STRINGIFY(s) AV_TOSTRING(s) -#define AV_TOSTRING(s) #s - -#define AV_GLUE(a, b) a ## b -#define AV_JOIN(a, b) AV_GLUE(a, b) - -#define AV_PRAGMA(s) _Pragma(#s) - -/** - * @} - */ +#include "macros.h" /** * @defgroup version_utils Library Version Macros @@ -58,7 +40,6 @@ * @} */ - /** * @file * @ingroup lavu @@ -75,7 +56,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 52 -#define LIBAVUTIL_VERSION_MINOR 58 +#define LIBAVUTIL_VERSION_MINOR 83 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -100,57 +81,69 @@ */ #ifndef FF_API_GET_BITS_PER_SAMPLE_FMT -#define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_FIND_OPT -#define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_FIND_OPT (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_OLD_AVOPTIONS -#define FF_API_OLD_AVOPTIONS (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_OLD_AVOPTIONS (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_PIX_FMT -#define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_PIX_FMT (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_CONTEXT_SIZE -#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_CONTEXT_SIZE (LIBAVUTIL_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_PIX_FMT_DESC +#define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 54) #endif -// TODO(dalecurtis): Remove when libavutil > 52. We don't care about this API, -// but without this it'll generate spammy deprecation warnings. -// #ifndef FF_API_PIX_FMT_DESC -// #define FF_API_PIX_FMT_DESC (LIBAVUTIL_VERSION_MAJOR < 53) -// #endif #ifndef FF_API_AV_REVERSE -#define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_AV_REVERSE (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_AUDIOCONVERT -#define FF_API_AUDIOCONVERT (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_AUDIOCONVERT (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_CPU_FLAG_MMX2 -#define FF_API_CPU_FLAG_MMX2 (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_CPU_FLAG_MMX2 (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_SAMPLES_UTILS_RETURN_ZERO -#define FF_API_SAMPLES_UTILS_RETURN_ZERO (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_SAMPLES_UTILS_RETURN_ZERO (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_LLS_PRIVATE -#define FF_API_LLS_PRIVATE (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_LLS_PRIVATE (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_LLS1 -#define FF_API_LLS1 (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_LLS1 (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_AVFRAME_LAVC -#define FF_API_AVFRAME_LAVC (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_AVFRAME_LAVC (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_VDPAU -#define FF_API_VDPAU (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_VDPAU (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_GET_CHANNEL_LAYOUT_COMPAT -#define FF_API_GET_CHANNEL_LAYOUT_COMPAT (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_GET_CHANNEL_LAYOUT_COMPAT (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_OLD_OPENCL -#define FF_API_OLD_OPENCL (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_OLD_OPENCL (LIBAVUTIL_VERSION_MAJOR < 54) #endif #ifndef FF_API_XVMC -#define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 53) +#define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_INTFLOAT +#define FF_API_INTFLOAT (LIBAVUTIL_VERSION_MAJOR < 54) +#endif +#ifndef FF_API_OPT_TYPE_METADATA +#define FF_API_OPT_TYPE_METADATA (LIBAVUTIL_VERSION_MAJOR < 54) +#endif + +#ifndef FF_CONST_AVUTIL53 +#if LIBAVUTIL_VERSION_MAJOR >= 53 +#define FF_CONST_AVUTIL53 const +#else +#define FF_CONST_AVUTIL53 +#endif #endif /** diff --git a/chromium/third_party/ffmpeg/libavutil/x86/asm.h b/chromium/third_party/ffmpeg/libavutil/x86/asm.h index 70ccac78852..2cecc980a5b 100644 --- a/chromium/third_party/ffmpeg/libavutil/x86/asm.h +++ b/chromium/third_party/ffmpeg/libavutil/x86/asm.h @@ -107,6 +107,46 @@ typedef int x86_reg; # define LOCAL_MANGLE(a) #a #endif -#define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) +#if HAVE_INLINE_ASM_DIRECT_SYMBOL_REFS +# define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a) +# define NAMED_CONSTRAINTS_ADD(...) +# define NAMED_CONSTRAINTS(...) +# define NAMED_CONSTRAINTS_ARRAY_ADD(...) +# define NAMED_CONSTRAINTS_ARRAY(...) +#else + /* When direct symbol references are used in code passed to a compiler that does not support them + * then these references need to be converted to named asm constraints instead. + * Instead of returning a direct symbol MANGLE now returns a named constraint for that specific symbol. + * In order for this to work there must also be a corresponding entry in the asm-interface. To add this + * entry use the macro NAMED_CONSTRAINTS() and pass in a list of each symbol reference used in the + * corresponding block of code. (e.g. NAMED_CONSTRAINTS(var1,var2,var3) where var1 is the first symbol etc. ). + * If there are already existing constraints then use NAMED_CONSTRAINTS_ADD to add to the existing constraint list. + */ +# define MANGLE(a) "%["#a"]" + // Intel/MSVC does not correctly expand va-args so we need a rather ugly hack in order to get it to work +# define FE_0(P,X) P(X) +# define FE_1(P,X,X1) P(X), FE_0(P,X1) +# define FE_2(P,X,X1,X2) P(X), FE_1(P,X1,X2) +# define FE_3(P,X,X1,X2,X3) P(X), FE_2(P,X1,X2,X3) +# define FE_4(P,X,X1,X2,X3,X4) P(X), FE_3(P,X1,X2,X3,X4) +# define FE_5(P,X,X1,X2,X3,X4,X5) P(X), FE_4(P,X1,X2,X3,X4,X5) +# define FE_6(P,X,X1,X2,X3,X4,X5,X6) P(X), FE_5(P,X1,X2,X3,X4,X5,X6) +# define FE_7(P,X,X1,X2,X3,X4,X5,X6,X7) P(X), FE_6(P,X1,X2,X3,X4,X5,X6,X7) +# define FE_8(P,X,X1,X2,X3,X4,X5,X6,X7,X8) P(X), FE_7(P,X1,X2,X3,X4,X5,X6,X7,X8) +# define FE_9(P,X,X1,X2,X3,X4,X5,X6,X7,X8,X9) P(X), FE_8(P,X1,X2,X3,X4,X5,X6,X7,X8,X9) +# define GET_FE_IMPL(_0,_1,_2,_3,_4,_5,_6,_7,_8,_9,NAME,...) NAME +# define GET_FE(A) GET_FE_IMPL A +# define GET_FE_GLUE(x, y) x y +# define FOR_EACH_VA(P,...) GET_FE_GLUE(GET_FE((__VA_ARGS__,FE_9,FE_8,FE_7,FE_6,FE_5,FE_4,FE_3,FE_2,FE_1,FE_0)), (P,__VA_ARGS__)) +# define NAME_CONSTRAINT(x) [x] "m"(x) + // Parameters are a list of each symbol reference required +# define NAMED_CONSTRAINTS_ADD(...) , FOR_EACH_VA(NAME_CONSTRAINT,__VA_ARGS__) + // Same but without comma for when there are no previously defined constraints +# define NAMED_CONSTRAINTS(...) FOR_EACH_VA(NAME_CONSTRAINT,__VA_ARGS__) + // Same as above NAMED_CONSTRAINTS except used for passing arrays/pointers instead of normal variables +# define NAME_CONSTRAINT_ARRAY(x) [x] "m"(*x) +# define NAMED_CONSTRAINTS_ARRAY_ADD(...) , FOR_EACH_VA(NAME_CONSTRAINT_ARRAY,__VA_ARGS__) +# define NAMED_CONSTRAINTS_ARRAY(...) FOR_EACH_VA(NAME_CONSTRAINT_ARRAY,__VA_ARGS__) +#endif #endif /* AVUTIL_X86_ASM_H */ diff --git a/chromium/third_party/ffmpeg/libavutil/x86/cpu.c b/chromium/third_party/ffmpeg/libavutil/x86/cpu.c index 18049eaead4..8ad478400c8 100644 --- a/chromium/third_party/ffmpeg/libavutil/x86/cpu.c +++ b/chromium/third_party/ffmpeg/libavutil/x86/cpu.c @@ -131,19 +131,27 @@ int ff_get_cpu_flags_x86(void) if ((ecx & 0x18000000) == 0x18000000) { /* Check for OS support */ xgetbv(0, eax, edx); - if ((eax & 0x6) == 0x6) + if ((eax & 0x6) == 0x6) { rval |= AV_CPU_FLAG_AVX; + if (ecx & 0x00001000) + rval |= AV_CPU_FLAG_FMA3; + } } -#if HAVE_AVX2 +#endif /* HAVE_AVX */ +#endif /* HAVE_SSE */ + } if (max_std_level >= 7) { cpuid(7, eax, ebx, ecx, edx); - if (ebx&0x00000020) +#if HAVE_AVX2 + if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x00000020)) rval |= AV_CPU_FLAG_AVX2; - /* TODO: BMI1/2 */ - } #endif /* HAVE_AVX2 */ -#endif /* HAVE_AVX */ -#endif /* HAVE_SSE */ + /* BMI1/2 don't need OS support */ + if (ebx & 0x00000008) { + rval |= AV_CPU_FLAG_BMI1; + if (ebx & 0x00000100) + rval |= AV_CPU_FLAG_BMI2; + } } cpuid(0x80000000, max_ext_level, ebx, ecx, edx); diff --git a/chromium/third_party/ffmpeg/libavutil/x86/cpu.h b/chromium/third_party/ffmpeg/libavutil/x86/cpu.h index 3724357e74a..bc64b1b3bd9 100644 --- a/chromium/third_party/ffmpeg/libavutil/x86/cpu.h +++ b/chromium/third_party/ffmpeg/libavutil/x86/cpu.h @@ -37,6 +37,8 @@ #define X86_SSE4(flags) CPUEXT(flags, SSE4) #define X86_SSE42(flags) CPUEXT(flags, SSE42) #define X86_AVX(flags) CPUEXT(flags, AVX) +#define X86_XOP(flags) CPUEXT(flags, XOP) +#define X86_FMA3(flags) CPUEXT(flags, FMA3) #define X86_FMA4(flags) CPUEXT(flags, FMA4) #define X86_AVX2(flags) CPUEXT(flags, AVX2) @@ -51,6 +53,8 @@ #define EXTERNAL_SSE4(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE4) #define EXTERNAL_SSE42(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, SSE42) #define EXTERNAL_AVX(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX) +#define EXTERNAL_XOP(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, XOP) +#define EXTERNAL_FMA3(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, FMA3) #define EXTERNAL_FMA4(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, FMA4) #define EXTERNAL_AVX2(flags) CPUEXT_SUFFIX(flags, _EXTERNAL, AVX2) @@ -65,6 +69,8 @@ #define INLINE_SSE4(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE4) #define INLINE_SSE42(flags) CPUEXT_SUFFIX(flags, _INLINE, SSE42) #define INLINE_AVX(flags) CPUEXT_SUFFIX(flags, _INLINE, AVX) +#define INLINE_XOP(flags) CPUEXT_SUFFIX(flags, _INLINE, XOP) +#define INLINE_FMA3(flags) CPUEXT_SUFFIX(flags, _INLINE, FMA3) #define INLINE_FMA4(flags) CPUEXT_SUFFIX(flags, _INLINE, FMA4) #define INLINE_AVX2(flags) CPUEXT_SUFFIX(flags, _INLINE, AVX2) diff --git a/chromium/third_party/ffmpeg/libavutil/x86/float_dsp.asm b/chromium/third_party/ffmpeg/libavutil/x86/float_dsp.asm index 49d4876447a..a5fcffb30b7 100644 --- a/chromium/third_party/ffmpeg/libavutil/x86/float_dsp.asm +++ b/chromium/third_party/ffmpeg/libavutil/x86/float_dsp.asm @@ -29,17 +29,21 @@ SECTION .text ;----------------------------------------------------------------------------- %macro VECTOR_FMUL 0 cglobal vector_fmul, 4,4,2, dst, src0, src1, len - lea lenq, [lend*4 - 2*mmsize] + lea lenq, [lend*4 - 64] ALIGN 16 .loop: - mova m0, [src0q + lenq] - mova m1, [src0q + lenq + mmsize] - mulps m0, m0, [src1q + lenq] - mulps m1, m1, [src1q + lenq + mmsize] - mova [dstq + lenq], m0 - mova [dstq + lenq + mmsize], m1 +%assign a 0 +%rep 32/mmsize + mova m0, [src0q + lenq + (a+0)*mmsize] + mova m1, [src0q + lenq + (a+1)*mmsize] + mulps m0, m0, [src1q + lenq + (a+0)*mmsize] + mulps m1, m1, [src1q + lenq + (a+1)*mmsize] + mova [dstq + lenq + (a+0)*mmsize], m0 + mova [dstq + lenq + (a+1)*mmsize], m1 +%assign a a+2 +%endrep - sub lenq, 2*mmsize + sub lenq, 64 jge .loop REP_RET %endmacro @@ -57,30 +61,49 @@ VECTOR_FMUL %macro VECTOR_FMAC_SCALAR 0 %if UNIX64 -cglobal vector_fmac_scalar, 3,3,3, dst, src, len +cglobal vector_fmac_scalar, 3,3,5, dst, src, len %else -cglobal vector_fmac_scalar, 4,4,3, dst, src, mul, len +cglobal vector_fmac_scalar, 4,4,5, dst, src, mul, len %endif %if ARCH_X86_32 VBROADCASTSS m0, mulm %else %if WIN64 - mova xmm0, xmm2 + SWAP 0, 2 %endif - shufps xmm0, xmm0, 0 + shufps xm0, xm0, 0 %if cpuflag(avx) - vinsertf128 m0, m0, xmm0, 1 + vinsertf128 m0, m0, xm0, 1 %endif %endif - lea lenq, [lend*4-2*mmsize] + lea lenq, [lend*4-64] .loop: - mulps m1, m0, [srcq+lenq ] - mulps m2, m0, [srcq+lenq+mmsize] - addps m1, m1, [dstq+lenq ] - addps m2, m2, [dstq+lenq+mmsize] - mova [dstq+lenq ], m1 - mova [dstq+lenq+mmsize], m2 - sub lenq, 2*mmsize +%if cpuflag(fma3) + mova m1, [dstq+lenq] + mova m2, [dstq+lenq+1*mmsize] + fmaddps m1, m0, [srcq+lenq], m1 + fmaddps m2, m0, [srcq+lenq+1*mmsize], m2 +%else ; cpuflag + mulps m1, m0, [srcq+lenq] + mulps m2, m0, [srcq+lenq+1*mmsize] +%if mmsize < 32 + mulps m3, m0, [srcq+lenq+2*mmsize] + mulps m4, m0, [srcq+lenq+3*mmsize] +%endif ; mmsize + addps m1, m1, [dstq+lenq] + addps m2, m2, [dstq+lenq+1*mmsize] +%if mmsize < 32 + addps m3, m3, [dstq+lenq+2*mmsize] + addps m4, m4, [dstq+lenq+3*mmsize] +%endif ; mmsize +%endif ; cpuflag + mova [dstq+lenq], m1 + mova [dstq+lenq+1*mmsize], m2 +%if mmsize < 32 + mova [dstq+lenq+2*mmsize], m3 + mova [dstq+lenq+3*mmsize], m4 +%endif ; mmsize + sub lenq, 64 jge .loop REP_RET %endmacro @@ -91,6 +114,10 @@ VECTOR_FMAC_SCALAR INIT_YMM avx VECTOR_FMAC_SCALAR %endif +%if HAVE_FMA3_EXTERNAL +INIT_YMM fma3 +VECTOR_FMAC_SCALAR +%endif ;------------------------------------------------------------------------------ ; void ff_vector_fmul_scalar(float *dst, const float *src, float mul, int len) @@ -139,16 +166,11 @@ cglobal vector_dmul_scalar, 4,4,3, dst, src, mul, len VBROADCASTSD m0, mulm %else %if WIN64 - movlhps xmm2, xmm2 -%if cpuflag(avx) - vinsertf128 ymm2, ymm2, xmm2, 1 -%endif SWAP 0, 2 -%else - movlhps xmm0, xmm0 -%if cpuflag(avx) - vinsertf128 ymm0, ymm0, xmm0, 1 %endif + movlhps xm0, xm0 +%if cpuflag(avx) + vinsertf128 ym0, ym0, xm0, 1 %endif %endif lea lenq, [lend*8-2*mmsize] @@ -174,16 +196,23 @@ VECTOR_DMUL_SCALAR ; const float *src2, int len) ;----------------------------------------------------------------------------- %macro VECTOR_FMUL_ADD 0 -cglobal vector_fmul_add, 5,5,2, dst, src0, src1, src2, len +cglobal vector_fmul_add, 5,5,4, dst, src0, src1, src2, len lea lenq, [lend*4 - 2*mmsize] ALIGN 16 .loop: mova m0, [src0q + lenq] mova m1, [src0q + lenq + mmsize] +%if cpuflag(fma3) + mova m2, [src2q + lenq] + mova m3, [src2q + lenq + mmsize] + fmaddps m0, m0, [src1q + lenq], m2 + fmaddps m1, m1, [src1q + lenq + mmsize], m3 +%else mulps m0, m0, [src1q + lenq] mulps m1, m1, [src1q + lenq + mmsize] addps m0, m0, [src2q + lenq] addps m1, m1, [src2q + lenq + mmsize] +%endif mova [dstq + lenq], m0 mova [dstq + lenq + mmsize], m1 @@ -198,6 +227,10 @@ VECTOR_FMUL_ADD INIT_YMM avx VECTOR_FMUL_ADD %endif +%if HAVE_FMA3_EXTERNAL +INIT_YMM fma3 +VECTOR_FMUL_ADD +%endif ;----------------------------------------------------------------------------- ; void vector_fmul_reverse(float *dst, const float *src0, const float *src1, diff --git a/chromium/third_party/ffmpeg/libavutil/x86/float_dsp_init.c b/chromium/third_party/ffmpeg/libavutil/x86/float_dsp_init.c index 97f7b7c7cae..88ffbc11b5e 100644 --- a/chromium/third_party/ffmpeg/libavutil/x86/float_dsp_init.c +++ b/chromium/third_party/ffmpeg/libavutil/x86/float_dsp_init.c @@ -33,6 +33,8 @@ void ff_vector_fmac_scalar_sse(float *dst, const float *src, float mul, int len); void ff_vector_fmac_scalar_avx(float *dst, const float *src, float mul, int len); +void ff_vector_fmac_scalar_fma3(float *dst, const float *src, float mul, + int len); void ff_vector_fmul_scalar_sse(float *dst, const float *src, float mul, int len); @@ -46,6 +48,8 @@ void ff_vector_fmul_add_sse(float *dst, const float *src0, const float *src1, const float *src2, int len); void ff_vector_fmul_add_avx(float *dst, const float *src0, const float *src1, const float *src2, int len); +void ff_vector_fmul_add_fma3(float *dst, const float *src0, const float *src1, + const float *src2, int len); void ff_vector_fmul_reverse_sse(float *dst, const float *src0, const float *src1, int len); @@ -153,4 +157,8 @@ av_cold void ff_float_dsp_init_x86(AVFloatDSPContext *fdsp) fdsp->vector_fmul_add = ff_vector_fmul_add_avx; fdsp->vector_fmul_reverse = ff_vector_fmul_reverse_avx; } + if (EXTERNAL_FMA3(cpu_flags)) { + fdsp->vector_fmac_scalar = ff_vector_fmac_scalar_fma3; + fdsp->vector_fmul_add = ff_vector_fmul_add_fma3; + } } diff --git a/chromium/third_party/ffmpeg/libavutil/x86/timer.h b/chromium/third_party/ffmpeg/libavutil/x86/timer.h index d812d46aed3..5b24b511c1f 100644 --- a/chromium/third_party/ffmpeg/libavutil/x86/timer.h +++ b/chromium/third_party/ffmpeg/libavutil/x86/timer.h @@ -25,6 +25,7 @@ #if HAVE_INLINE_ASM +#define FF_TIMER_UNITS "decicycles" #define AV_READ_TIME read_time static inline uint64_t read_time(void) diff --git a/chromium/third_party/ffmpeg/libavutil/x86/x86inc.asm b/chromium/third_party/ffmpeg/libavutil/x86/x86inc.asm index 420e293f689..a7f9f543670 100644 --- a/chromium/third_party/ffmpeg/libavutil/x86/x86inc.asm +++ b/chromium/third_party/ffmpeg/libavutil/x86/x86inc.asm @@ -1058,25 +1058,25 @@ INIT_XMM ;%5+: operands %macro RUN_AVX_INSTR 5-8+ %ifnum sizeof%6 - %assign %%sizeofreg sizeof%6 + %assign __sizeofreg sizeof%6 %elifnum sizeof%5 - %assign %%sizeofreg sizeof%5 + %assign __sizeofreg sizeof%5 %else - %assign %%sizeofreg mmsize + %assign __sizeofreg mmsize %endif - %assign %%emulate_avx 0 - %if avx_enabled && %%sizeofreg >= 16 - %xdefine %%instr v%1 + %assign __emulate_avx 0 + %if avx_enabled && __sizeofreg >= 16 + %xdefine __instr v%1 %else - %xdefine %%instr %1 + %xdefine __instr %1 %if %0 >= 7+%3 - %assign %%emulate_avx 1 + %assign __emulate_avx 1 %endif %endif - %if %%emulate_avx - %xdefine %%src1 %6 - %xdefine %%src2 %7 + %if __emulate_avx + %xdefine __src1 %6 + %xdefine __src2 %7 %ifnidn %5, %6 %if %0 >= 8 CHECK_AVX_INSTR_EMU {%1 %5, %6, %7, %8}, %5, %7, %8 @@ -1088,31 +1088,31 @@ INIT_XMM ; 3-operand AVX instructions with a memory arg can only have it in src2, ; whereas SSE emulation prefers to have it in src1 (i.e. the mov). ; So, if the instruction is commutative with a memory arg, swap them. - %xdefine %%src1 %7 - %xdefine %%src2 %6 + %xdefine __src1 %7 + %xdefine __src2 %6 %endif %endif - %if %%sizeofreg == 8 - MOVQ %5, %%src1 + %if __sizeofreg == 8 + MOVQ %5, __src1 %elif %2 - MOVAPS %5, %%src1 + MOVAPS %5, __src1 %else - MOVDQA %5, %%src1 + MOVDQA %5, __src1 %endif %endif %if %0 >= 8 - %1 %5, %%src2, %8 + %1 %5, __src2, %8 %else - %1 %5, %%src2 + %1 %5, __src2 %endif %elif %0 >= 8 - %%instr %5, %6, %7, %8 + __instr %5, %6, %7, %8 %elif %0 == 7 - %%instr %5, %6, %7 + __instr %5, %6, %7 %elif %0 == 6 - %%instr %5, %6 + __instr %5, %6 %else - %%instr %5 + __instr %5 %endif %endmacro @@ -1407,21 +1407,6 @@ AVX_INSTR pfmul, 1, 0, 1 %undef i %undef j -%macro FMA_INSTR 3 - %macro %1 4-7 %1, %2, %3 - %if cpuflag(xop) - v%5 %1, %2, %3, %4 - %else - %6 %1, %2, %3 - %7 %1, %4 - %endif - %endmacro -%endmacro - -FMA_INSTR pmacsdd, pmulld, paddd -FMA_INSTR pmacsww, pmullw, paddw -FMA_INSTR pmadcswd, pmaddwd, paddd - ; tzcnt is equivalent to "rep bsf" and is backwards-compatible with bsf. ; This lets us use tzcnt without bumping the yasm version requirement yet. %define tzcnt rep bsf diff --git a/chromium/third_party/ffmpeg/libavutil/x86/x86util.asm b/chromium/third_party/ffmpeg/libavutil/x86/x86util.asm index 59e5df248e5..67d79051328 100644 --- a/chromium/third_party/ffmpeg/libavutil/x86/x86util.asm +++ b/chromium/third_party/ffmpeg/libavutil/x86/x86util.asm @@ -273,6 +273,39 @@ %endif %endmacro +%macro HADDD 2 ; sum junk +%if sizeof%1 == 32 +%define %2 xmm%2 + vextracti128 %2, %1, 1 +%define %1 xmm%1 + paddd %1, %2 +%endif +%if mmsize >= 16 +%if cpuflag(xop) && sizeof%1 == 16 + vphadddq %1, %1 +%endif + movhlps %2, %1 + paddd %1, %2 +%endif +%if notcpuflag(xop) || sizeof%1 != 16 + PSHUFLW %2, %1, q0032 + paddd %1, %2 +%endif +%undef %1 +%undef %2 +%endmacro + +%macro HADDW 2 ; reg, tmp +%if cpuflag(xop) && sizeof%1 == 16 + vphaddwq %1, %1 + movhlps %2, %1 + paddd %1, %2 +%else + pmaddwd %1, [pw_1] + HADDD %1, %2 +%endif +%endmacro + %macro PALIGNR 4-5 %if cpuflag(ssse3) %if %0==5 @@ -666,6 +699,25 @@ %endif %endmacro +%macro PMA_EMU 4 + %macro %1 5-8 %2, %3, %4 + %if cpuflag(xop) + v%6 %1, %2, %3, %4 + %elifidn %1, %4 + %7 %5, %2, %3 + %8 %1, %4, %5 + %else + %7 %1, %2, %3 + %8 %1, %4 + %endif + %endmacro +%endmacro + +PMA_EMU PMACSWW, pmacsww, pmullw, paddw +PMA_EMU PMACSDD, pmacsdd, pmulld, paddd ; sse4 emulation +PMA_EMU PMACSDQL, pmacsdql, pmuldq, paddq ; sse4 emulation +PMA_EMU PMADCSWD, pmadcswd, pmaddwd, paddd + ; Wrapper for non-FMA version of fmaddps %macro FMULADD_PS 5 %if cpuflag(fma3) || cpuflag(fma4) |