From 3b02429c8a0b476120cb1bc63c9ddd4a3a44a37b Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Mon, 2 Feb 2015 00:22:51 -0500 Subject: gnu: libvpx: Apply bug fixes. Fixes build on armhf. * gnu/packages/patches/libvpx-fix-armhf-link.patch, gnu/packages/patches/libvpx-fix-ssse3-quantize.patch, gnu/packages/patches/libvpx-vp9-out-of-bounds-access.patch: New files. * gnu-system.am (dist_patch_DATA): Add them. * gnu/packages/video.scm (libvpx): Add patches. On armhf, add additional configure flags to avoid requiring support for NEON. --- gnu/packages/patches/libvpx-fix-armhf-link.patch | 23 ++++++++++++++ .../patches/libvpx-fix-ssse3-quantize.patch | 32 ++++++++++++++++++++ .../patches/libvpx-vp9-out-of-bounds-access.patch | 35 ++++++++++++++++++++++ gnu/packages/video.scm | 28 +++++++++++++++-- 4 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 gnu/packages/patches/libvpx-fix-armhf-link.patch create mode 100644 gnu/packages/patches/libvpx-fix-ssse3-quantize.patch create mode 100644 gnu/packages/patches/libvpx-vp9-out-of-bounds-access.patch (limited to 'gnu') diff --git a/gnu/packages/patches/libvpx-fix-armhf-link.patch b/gnu/packages/patches/libvpx-fix-armhf-link.patch new file mode 100644 index 0000000000..e0b998d487 --- /dev/null +++ b/gnu/packages/patches/libvpx-fix-armhf-link.patch @@ -0,0 +1,23 @@ +This patch was copied from Debian. It is needed on armhf. + +--- a/build/make/configure.sh 2013-12-17 18:18:46.904410454 +0100 ++++ b/build/make/configure.sh 2013-12-17 18:19:58.720758736 +0100 +@@ -799,7 +799,6 @@ + + case ${tgt_cc} in + gcc) +- CROSS=${CROSS:-arm-none-linux-gnueabi-} + link_with_cc=gcc + setup_gnu_toolchain + arch_int=${tgt_isa##armv} +@@ -822,10 +821,6 @@ + check_add_cflags -mfpu=neon #-ftree-vectorize + check_add_asflags -mfpu=neon + fi +- +- if [ -z "${tune_cpu}" ]; then +- tune_cpu=cortex-a8 +- fi + else + check_add_cflags -march=${tgt_isa} + check_add_asflags -march=${tgt_isa} diff --git a/gnu/packages/patches/libvpx-fix-ssse3-quantize.patch b/gnu/packages/patches/libvpx-fix-ssse3-quantize.patch new file mode 100644 index 0000000000..74138e8d49 --- /dev/null +++ b/gnu/packages/patches/libvpx-fix-ssse3-quantize.patch @@ -0,0 +1,32 @@ +commit 0d43bd77e5f429467fbd280a7b8f7fbc0bfe1809 +Author: Yunqing Wang +Date: Fri Feb 7 14:27:07 2014 -0800 + + Bug fix in ssse3 quantize function + + A bug was reported in Issue 702: "SIGILL (Illegal instruction) when + transcoding with vp9 - using FFmpeg". It was reproduced and fixed. + + Change-Id: Ie32c149a89af02856084aeaf289e848a905c7700 + +diff --git a/vp9/encoder/x86/vp9_quantize_ssse3.asm b/vp9/encoder/x86/vp9_quantize_ssse3.asm +index db30660..48ccef8 100644 +--- a/vp9/encoder/x86/vp9_quantize_ssse3.asm ++++ b/vp9/encoder/x86/vp9_quantize_ssse3.asm +@@ -188,7 +188,8 @@ cglobal quantize_%1, 0, %2, 15, coeff, ncoeff, skip, zbin, round, quant, \ + pmaxsw m8, m7 + pshuflw m7, m8, 0x1 + pmaxsw m8, m7 +- pextrw [r2], m8, 0 ++ pextrw r6, m8, 0 ++ mov [r2], r6 + RET + + ; skip-block, i.e. just write all zeroes +@@ -214,5 +215,5 @@ cglobal quantize_%1, 0, %2, 15, coeff, ncoeff, skip, zbin, round, quant, \ + %endmacro + + INIT_XMM ssse3 +-QUANTIZE_FN b, 6 ++QUANTIZE_FN b, 7 + QUANTIZE_FN b_32x32, 7 diff --git a/gnu/packages/patches/libvpx-vp9-out-of-bounds-access.patch b/gnu/packages/patches/libvpx-vp9-out-of-bounds-access.patch new file mode 100644 index 0000000000..6aec8aa2f0 --- /dev/null +++ b/gnu/packages/patches/libvpx-vp9-out-of-bounds-access.patch @@ -0,0 +1,35 @@ +Copied from Debian. + +# HG changeset patch +# User Ralph Giles +# Date 1412209683 25200 +# Node ID 6023f0b4f8ba49dd117106cc98cd8007c2142bf6 +# Parent 8c431dcec0ffde13988d47eacf341113ea883245 +Bug 1063327 - Reject vp9 frames with invalid tiles. r=kinetik, a=abillings + +diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c +--- a/vp9/decoder/vp9_decodframe.c ++++ b/vp9/decoder/vp9_decodframe.c +@@ -863,16 +863,21 @@ static size_t get_tile(const uint8_t *co + + if (!is_last) { + if (!read_is_valid(*data, 4, data_end)) + vpx_internal_error(error_info, VPX_CODEC_CORRUPT_FRAME, + "Truncated packet or corrupt tile length"); + + size = read_be32(*data); + *data += 4; ++ ++ if (size > data_end - *data) { ++ vpx_internal_error(error_info, VPX_CODEC_CORRUPT_FRAME, ++ "Truncated packet or corrupt tile size"); ++ } + } else { + size = data_end - *data; + } + return size; + } + + typedef struct TileBuffer { + const uint8_t *data; + diff --git a/gnu/packages/video.scm b/gnu/packages/video.scm index 9cdfbf11da..098f6eb215 100644 --- a/gnu/packages/video.scm +++ b/gnu/packages/video.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014 Andreas Enge ;;; Copyright © 2014 David Thompson -;;; Copyright © 2014 Mark H Weaver +;;; Copyright © 2014, 2015 Mark H Weaver ;;; ;;; This file is part of GNU Guix. ;;; @@ -26,6 +26,7 @@ #:use-module (guix download) #:use-module (guix build-system gnu) #:use-module (guix build-system python) + #:use-module (gnu packages) #:use-module (gnu packages algebra) #:use-module (gnu packages avahi) #:use-module (gnu packages cdrom) @@ -371,10 +372,14 @@ SVCD, DVD, 3ivx, DivX 3/4/5, WMV and H.264 movies.") version ".tar.bz2")) (sha256 (base32 - "1aai0h0z1bhp89pxmg4fkrwpmqq24k39fhr15cw6q77m9bccip6k")))) + "1aai0h0z1bhp89pxmg4fkrwpmqq24k39fhr15cw6q77m9bccip6k")) + (patches + (list (search-patch "libvpx-vp9-out-of-bounds-access.patch") + (search-patch "libvpx-fix-ssse3-quantize.patch") + (search-patch "libvpx-fix-armhf-link.patch"))))) (build-system gnu-build-system) (arguments - '(#:phases (alist-replace + `(#:phases (alist-replace 'configure (lambda* (#:key outputs #:allow-other-keys) (setenv "CONFIG_SHELL" (which "bash")) @@ -382,6 +387,23 @@ SVCD, DVD, 3ivx, DivX 3/4/5, WMV and H.264 movies.") (zero? (system* "./configure" "--enable-shared" "--as=yasm" + ,@(if (and (not (%current-target-system)) + (string-prefix? + "armhf-" + (%current-system))) + ;; When building on ARMv7, libvpx + ;; assumes that NEON will be + ;; available. On Guix, armhf + ;; does not require NEON, so we + ;; build for ARMv6 and -marm (since + ;; no thumb2 on ARMv6) to ensure + ;; compatibility with all ARMv7 + ;; cores we support. Based on + ;; the Debian libvpx package. + '("--target=armv6-linux-gcc" + "--extra-cflags=-marm" + "--enable-small") + '()) (string-append "--prefix=" out))))) %standard-phases) #:tests? #f)) ; no check target -- cgit 1.4.1