Bug 1294490 - Part 2. Add build files to support libwebp decoding. r=glandium

Differential Revision: https://phabricator.services.mozilla.com/D8115
This commit is contained in:
Andrew Osmond 2018-10-03 17:40:26 -04:00
parent 29afb453e1
commit 26e5749b27
10 changed files with 364 additions and 0 deletions

View File

@ -57,6 +57,7 @@ external_dirs += [
'media/libtheora',
'media/libspeex_resampler',
'media/libsoundtouch',
'media/libwebp',
'media/mp4parse-rust',
'media/psshparser'
]

3
media/libwebp/MOZCHANGES Normal file
View File

@ -0,0 +1,3 @@
Changes made to pristine libwebp source by mozilla.org developers.
2018/10/04 -- Synced with libwebp-1.0.0 (bug #1294490).

28
media/libwebp/moz.build Normal file
View File

@ -0,0 +1,28 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files('**'):
BUG_COMPONENT = ('Core', 'ImageLib')
EXPORTS.webp += [
'src/webp/decode.h',
'src/webp/demux.h',
'src/webp/mux_types.h',
'src/webp/types.h',
]
DIRS += [
'src/dec',
'src/demux',
'src/dsp',
'src/moz',
'src/utils',
]
FINAL_LIBRARY = 'gkmedias'
# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()

View File

@ -0,0 +1,30 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files('**'):
BUG_COMPONENT = ('Core', 'ImageLib')
SOURCES += [
'alpha_dec.c',
'buffer_dec.c',
'frame_dec.c',
'idec_dec.c',
'io_dec.c',
'quant_dec.c',
'tree_dec.c',
'vp8_dec.c',
'vp8l_dec.c',
'webp_dec.c',
]
LOCAL_INCLUDES += [
'/media/libwebp',
]
FINAL_LIBRARY = 'gkmedias'
# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()

View File

@ -0,0 +1,21 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files('**'):
BUG_COMPONENT = ('Core', 'ImageLib')
SOURCES += [
'demux.c',
]
LOCAL_INCLUDES += [
'/media/libwebp',
]
FINAL_LIBRARY = 'gkmedias'
# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()

View File

@ -0,0 +1,94 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files('**'):
BUG_COMPONENT = ('Core', 'ImageLib')
SOURCES += [
'alpha_processing.c',
'dec.c',
'dec_clip_tables.c',
'filters.c',
'lossless.c',
'rescaler.c',
'upsampling.c',
'yuv.c',
]
LOCAL_INCLUDES += [
'/media/libwebp',
]
if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['BUILD_ARM_NEON']:
SOURCES += [
'alpha_processing_neon.c',
'dec_neon.c',
'filters_neon.c',
'lossless_neon.c',
'rescaler_neon.c',
'upsampling_neon.c',
'yuv_neon.c',
]
DEFINES['WEBP_HAVE_NEON'] = 1;
for f in SOURCES:
if f.endswith('neon.c'):
SOURCES[f].flags += CONFIG['NEON_FLAGS']
elif CONFIG['CPU_ARCH'] == 'aarch64':
SOURCES += [
'alpha_processing_neon.c',
'dec_neon.c',
'filters_neon.c',
'lossless_neon.c',
'rescaler_neon.c',
'upsampling_neon.c',
'yuv_neon.c',
]
DEFINES['WEBP_HAVE_NEON'] = 1;
elif CONFIG['INTEL_ARCHITECTURE']:
SOURCES += [
'alpha_processing_sse2.c',
'alpha_processing_sse41.c',
'dec_sse2.c',
'dec_sse41.c',
'filters_sse2.c',
'lossless_sse2.c',
'rescaler_sse2.c',
'upsampling_sse2.c',
'upsampling_sse41.c',
'yuv_sse2.c',
'yuv_sse41.c',
]
DEFINES['WEBP_HAVE_SSE2'] = 1;
DEFINES['WEBP_HAVE_SSE41'] = 1;
for f in SOURCES:
if f.endswith('sse2.c'):
SOURCES[f].flags += CONFIG['SSE2_FLAGS']
elif f.endswith('sse41.c'):
SOURCES[f].flags += ['-msse4.1']
elif CONFIG['CPU_ARCH'].startswith('mips'):
SOURCES += [
'alpha_processing_mips_dsp_r2.c',
'dec_mips32.c',
'dec_mips_dsp_r2.c',
'filters_mips_dsp_r2.c',
'lossless_mips_dsp_r2.c',
'lossless_msa.c',
'rescaler_mips32.c',
'rescaler_mips_dsp_r2.c',
'rescaler_msa.c',
'upsampling_mips_dsp_r2.c',
'upsampling_msa.c',
'yuv_mips32.c',
'yuv_mips_dsp_r2.c',
]
if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'):
CFLAGS += ['-Wno-unreachable-code']
FINAL_LIBRARY = 'gkmedias'
# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()

View File

@ -0,0 +1,40 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* This file replaces the CPU info methods originally implemented in
* src/dsp/cpu.c, due to missing dependencies for Andriod builds. It
* controls if NEON/SSE/etc is used. */
#include "../dsp/dsp.h"
#include "mozilla/arm.h"
#include "mozilla/SSE.h"
static int MozCPUInfo(CPUFeature feature)
{
switch (feature) {
case kSSE2:
return mozilla::supports_sse2();
case kSSE3:
return mozilla::supports_sse3();
case kSSE4_1:
return mozilla::supports_sse4_1();
case kAVX:
return mozilla::supports_avx();
case kAVX2:
return mozilla::supports_avx2();
case kNEON:
return mozilla::supports_neon();
#if defined(WEBP_USE_MIPS32) || defined(WEBP_USE_MIPS_DSP_R2) || defined(WEBP_USE_MSA)
case kMIPS32:
case kMIPSdspR2:
case kMSA:
return 1;
#endif
default:
return 0;
}
}
VP8CPUInfo VP8GetCPUInfo = MozCPUInfo;

View File

@ -0,0 +1,21 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files('**'):
BUG_COMPONENT = ('Core', 'ImageLib')
SOURCES += [
'cpu.cpp',
]
LOCAL_INCLUDES += [
'/media/libwebp',
]
FINAL_LIBRARY = 'gkmedias'
# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()

View File

@ -0,0 +1,30 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
with Files('**'):
BUG_COMPONENT = ('Core', 'ImageLib')
SOURCES += [
'bit_reader_utils.c',
'color_cache_utils.c',
'filters_utils.c',
'huffman_utils.c',
'quant_levels_dec_utils.c',
'quant_levels_utils.c',
'random_utils.c',
'rescaler_utils.c',
'thread_utils.c',
'utils.c',
]
LOCAL_INCLUDES += [
'/media/libwebp',
]
FINAL_LIBRARY = 'gkmedias'
# We allow warnings for third-party code that can be updated from upstream.
AllowCompilerWarnings()

96
media/libwebp/update.sh Executable file
View File

@ -0,0 +1,96 @@
#!/bin/sh
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Usage: ./update.sh <libwebp_directory>
#
# Copies the needed files from a directory containing the original
# libwebp source.
cp $1/AUTHORS .
cp $1/COPYING .
cp $1/NEWS .
cp $1/PATENTS .
cp $1/README .
cp $1/README.mux .
mkdir -p src/webp
cp $1/src/webp/*.h src/webp
mkdir -p src/dec
cp $1/src/dec/*.h src/dec
cp $1/src/dec/alpha_dec.c src/dec
cp $1/src/dec/buffer_dec.c src/dec
cp $1/src/dec/frame_dec.c src/dec
cp $1/src/dec/idec_dec.c src/dec
cp $1/src/dec/io_dec.c src/dec
cp $1/src/dec/quant_dec.c src/dec
cp $1/src/dec/tree_dec.c src/dec
cp $1/src/dec/vp8_dec.c src/dec
cp $1/src/dec/vp8l_dec.c src/dec
cp $1/src/dec/webp_dec.c src/dec
mkdir -p src/demux
cp $1/src/demux/demux.c src/demux
mkdir -p src/dsp
cp $1/src/dsp/*.h src/dsp
cp $1/src/dsp/alpha_processing.c src/dsp
cp $1/src/dsp/alpha_processing_mips_dsp_r2.c src/dsp
cp $1/src/dsp/alpha_processing_neon.c src/dsp
cp $1/src/dsp/alpha_processing_sse2.c src/dsp
cp $1/src/dsp/alpha_processing_sse41.c src/dsp
cp $1/src/dsp/dec.c src/dsp
cp $1/src/dsp/dec_clip_tables.c src/dsp
cp $1/src/dsp/dec_mips32.c src/dsp
cp $1/src/dsp/dec_mips_dsp_r2.c src/dsp
cp $1/src/dsp/dec_msa.c src/dsp
cp $1/src/dsp/dec_neon.c src/dsp
cp $1/src/dsp/dec_sse2.c src/dsp
cp $1/src/dsp/dec_sse41.c src/dsp
cp $1/src/dsp/filters.c src/dsp
cp $1/src/dsp/filters_mips_dsp_r2.c src/dsp
cp $1/src/dsp/filters_msa.c src/dsp
cp $1/src/dsp/filters_neon.c src/dsp
cp $1/src/dsp/filters_sse2.c src/dsp
cp $1/src/dsp/lossless.c src/dsp
cp $1/src/dsp/lossless_mips_dsp_r2.c src/dsp
cp $1/src/dsp/lossless_msa.c src/dsp
cp $1/src/dsp/lossless_neon.c src/dsp
cp $1/src/dsp/lossless_sse2.c src/dsp
cp $1/src/dsp/rescaler.c src/dsp
cp $1/src/dsp/rescaler_mips32.c src/dsp
cp $1/src/dsp/rescaler_mips_dsp_r2.c src/dsp
cp $1/src/dsp/rescaler_msa.c src/dsp
cp $1/src/dsp/rescaler_neon.c src/dsp
cp $1/src/dsp/rescaler_sse2.c src/dsp
cp $1/src/dsp/upsampling.c src/dsp
cp $1/src/dsp/upsampling_mips_dsp_r2.c src/dsp
cp $1/src/dsp/upsampling_msa.c src/dsp
cp $1/src/dsp/upsampling_neon.c src/dsp
cp $1/src/dsp/upsampling_sse2.c src/dsp
cp $1/src/dsp/upsampling_sse41.c src/dsp
cp $1/src/dsp/yuv.c src/dsp
cp $1/src/dsp/yuv_mips32.c src/dsp
cp $1/src/dsp/yuv_mips_dsp_r2.c src/dsp
cp $1/src/dsp/yuv_neon.c src/dsp
cp $1/src/dsp/yuv_sse2.c src/dsp
cp $1/src/dsp/yuv_sse41.c src/dsp
mkdir -p src/enc
cp $1/src/enc/*.h src/enc
mkdir -p src/utils
cp $1/src/utils/*.h src/utils
cp $1/src/utils/bit_reader_utils.c src/utils
cp $1/src/utils/color_cache_utils.c src/utils
cp $1/src/utils/filters_utils.c src/utils
cp $1/src/utils/huffman_utils.c src/utils
cp $1/src/utils/quant_levels_dec_utils.c src/utils
cp $1/src/utils/quant_levels_utils.c src/utils
cp $1/src/utils/random_utils.c src/utils
cp $1/src/utils/rescaler_utils.c src/utils
cp $1/src/utils/thread_utils.c src/utils
cp $1/src/utils/utils.c src/utils