Commit 563aeba9 authored by Deb Mukherjee's avatar Deb Mukherjee

Merge 'origin/master' into highbitdepth

Conflicts:
	examples/vp9_spatial_svc_encoder.c
	examples/vpx_temporal_svc_encoder.c
	test/convolve_test.cc
	test/dct16x16_test.cc
	test/dct32x32_test.cc
	test/fdct4x4_test.cc
	test/fdct8x8_test.cc
	test/lpf_8_test.cc
	test/partial_idct_test.cc
	test/test.mk
	test/vp9_intrapred_test.cc
	tools_common.c
	vp8/vp8_cx_iface.c
	vp9/common/vp9_alloccommon.c
	vp9/common/vp9_common.h
	vp9/common/vp9_convolve.c
	vp9/common/vp9_convolve.h
	vp9/common/vp9_entropy.c
	vp9/common/vp9_entropy.h
	vp9/common/vp9_idct.c
	vp9/common/vp9_idct.h
	vp9/common/vp9_loopfilter.c
	vp9/common/vp9_loopfilter_filters.c
	vp9/common/vp9_onyxc_int.h
	vp9/common/vp9_postproc.c
	vp9/common/vp9_quant_common.c
	vp9/common/vp9_quant_common.h
	vp9/common/vp9_reconinter.c
	vp9/common/vp9_reconinter.h
	vp9/common/vp9_reconintra.c
	vp9/common/vp9_rtcd_defs.pl
	vp9/common/vp9_scale.c
	vp9/common/vp9_scale.h
	vp9/common/x86/vp9_asm_stubs.c
	vp9/common/x86/vp9_high_intrapred_sse2.asm
	vp9/common/x86/vp9_high_loopfilter_intrin_sse2.c
	vp9/common/x86/vp9_high_subpixel_8t_sse2.asm
	vp9/common/x86/vp9_high_subpixel_bilinear_sse2.asm
	vp9/decoder/vp9_decodeframe.c
	vp9/decoder/vp9_detokenize.c
	vp9/encoder/vp9_aq_complexity.c
	vp9/encoder/vp9_aq_cyclicrefresh.c
	vp9/encoder/vp9_aq_variance.c
	vp9/encoder/vp9_bitstream.c
	vp9/encoder/vp9_block.h
	vp9/encoder/vp9_context_tree.h
	vp9/encoder/vp9_dct.c
	vp9/encoder/vp9_encodeframe.c
	vp9/encoder/vp9_encodemb.c
	vp9/encoder/vp9_encoder.c
	vp9/encoder/vp9_encoder.h
	vp9/encoder/vp9_extend.c
	vp9/encoder/vp9_firstpass.c
	vp9/encoder/vp9_lookahead.c
	vp9/encoder/vp9_lookahead.h
	vp9/encoder/vp9_mcomp.c
	vp9/encoder/vp9_picklpf.c
	vp9/encoder/vp9_pickmode.c
	vp9/encoder/vp9_quantize.c
	vp9/encoder/vp9_quantize.h
	vp9/encoder/vp9_ratectrl.c
	vp9/encoder/vp9_rd.c
	vp9/encoder/vp9_rdopt.c
	vp9/encoder/vp9_resize.c
	vp9/encoder/vp9_resize.h
	vp9/encoder/vp9_sad.c
	vp9/encoder/vp9_ssim.c
	vp9/encoder/vp9_ssim.h
	vp9/encoder/vp9_temporal_filter.c
	vp9/encoder/vp9_tokenize.c
	vp9/encoder/vp9_tokenize.h
	vp9/encoder/vp9_variance.c
	vp9/encoder/vp9_variance.h
	vp9/vp9_common.mk
	vp9/vp9_cx_iface.c
	vp9/vp9_dx_iface.c
	vp9/vp9_iface_common.h
	vpx/src/svc_encodeframe.c
	vpx/src/vpx_image.c
	vpx/vp8dx.h
	vpx/vpx_codec.h
	vpx/vpx_encoder.h
	vpx/vpx_image.h
	vpx_mem/vpx_mem.c
	vpx_mem/vpx_mem.h
	vpx_scale/generic/yv12config.c
	vpx_scale/generic/yv12extend.c
	vpx_scale/yv12config.h
	vpxdec.c
	vpxenc.c

Change-Id: I699c833f7da96569d2581af7e045ce523bf72d3b
parents 93657ee6 e59c053e
......@@ -65,6 +65,7 @@ COMPILING THE APPLICATIONS/LIBRARIES:
armv7-win32-vs12
armv7s-darwin-gcc
mips32-linux-gcc
mips64-linux-gcc
ppc32-darwin8-gcc
ppc32-darwin9-gcc
ppc32-linux-gcc
......
......@@ -736,6 +736,9 @@ process_common_toolchain() {
# PIC is probably what we want when building shared libs
enabled shared && soft_enable pic
# Minimum iOS version for all target platforms (darwin and iphonesimulator).
IOS_VERSION_MIN="6.0"
# Handle darwin variants. Newer SDKs allow targeting older
# platforms, so find the newest SDK available.
case ${toolchain} in
......@@ -788,8 +791,8 @@ process_common_toolchain() {
add_ldflags "-mmacosx-version-min=10.9"
;;
*-iphonesimulator-*)
add_cflags "-miphoneos-version-min=5.0"
add_ldflags "-miphoneos-version-min=5.0"
add_cflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
add_ldflags "-miphoneos-version-min=${IOS_VERSION_MIN}"
osx_sdk_dir="$(xcrun --sdk iphonesimulator --show-sdk-path)"
add_cflags "-isysroot ${osx_sdk_dir}"
add_ldflags "-isysroot ${osx_sdk_dir}"
......@@ -970,18 +973,28 @@ EOF
;;
darwin*)
XCRUN_FIND="xcrun --sdk iphoneos -find"
CXX="$(${XCRUN_FIND} clang++)"
CC="$(${XCRUN_FIND} clang)"
AR="$(${XCRUN_FIND} ar)"
LD="$(${XCRUN_FIND} ld)"
AS="$(${XCRUN_FIND} as)"
STRIP="$(${XCRUN_FIND} strip)"
NM="$(${XCRUN_FIND} nm)"
RANLIB="$(${XCRUN_FIND} ranlib)"
AS_SFX=.s
# Special handling of ld for armv6 because libclang_rt.ios.a does
# not contain armv6 support in Apple's clang package:
# Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn).
# TODO(tomfinegan): Remove this. Our minimum iOS version (6.0)
# renders support for armv6 unnecessary because the 3GS and up
# support neon.
if [ "${tgt_isa}" = "armv6" ]; then
LD="$(${XCRUN_FIND} ld)"
else
LD="${CXX:-$(${XCRUN_FIND} ld)}"
fi
# ASFLAGS is written here instead of using check_add_asflags
# because we need to overwrite all of ASFLAGS and purge the
# options that were put in above
......@@ -989,7 +1002,13 @@ EOF
alt_libc="$(xcrun --sdk iphoneos --show-sdk-path)"
add_cflags -arch ${tgt_isa} -isysroot ${alt_libc}
add_ldflags -arch ${tgt_isa} -ios_version_min 7.0
add_ldflags -arch ${tgt_isa}
if [ "${LD}" = "${CXX}" ]; then
add_ldflags -miphoneos-version-min="${IOS_VERSION_MIN}"
else
add_ldflags -ios_version_min "${IOS_VERSION_MIN}"
fi
for d in lib usr/lib usr/lib/system; do
try_dir="${alt_libc}/${d}"
......
......@@ -245,13 +245,13 @@ esac
case "$target" in
x86_64*)
platforms[0]="x64"
asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
asm_Debug_cmdline="yasm -Xvc -g cv8 -f win64 ${yasmincs} "\$(InputPath)""
asm_Release_cmdline="yasm -Xvc -f win64 ${yasmincs} "\$(InputPath)""
;;
x86*)
platforms[0]="Win32"
asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} "\$(InputPath)""
asm_Debug_cmdline="yasm -Xvc -g cv8 -f win32 ${yasmincs} "\$(InputPath)""
asm_Release_cmdline="yasm -Xvc -f win32 ${yasmincs} "\$(InputPath)""
;;
*) die "Unsupported target $target!"
;;
......
......@@ -253,13 +253,13 @@ libs=${libs// /;}
case "$target" in
x86_64*)
platforms[0]="x64"
asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} "%(FullPath)""
asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} "%(FullPath)""
asm_Debug_cmdline="yasm -Xvc -g cv8 -f win64 ${yasmincs} "%(FullPath)""
asm_Release_cmdline="yasm -Xvc -f win64 ${yasmincs} "%(FullPath)""
;;
x86*)
platforms[0]="Win32"
asm_Debug_cmdline="yasm -Xvc -g cv8 -f \$(PlatformName) ${yasmincs} "%(FullPath)""
asm_Release_cmdline="yasm -Xvc -f \$(PlatformName) ${yasmincs} "%(FullPath)""
asm_Debug_cmdline="yasm -Xvc -g cv8 -f win32 ${yasmincs} "%(FullPath)""
asm_Release_cmdline="yasm -Xvc -f win32 ${yasmincs} "%(FullPath)""
;;
arm*)
asm_Debug_cmdline="armasm -nologo "%(FullPath)""
......
......@@ -43,7 +43,7 @@ build_target() {
mkdir "${target}"
cd "${target}"
eval "../../${LIBVPX_SOURCE_DIR}/configure" --target="${target}" \
--disable-docs ${devnull}
--disable-docs ${EXTRA_CONFIGURE_ARGS} ${devnull}
export DIST_DIR
eval make -j ${MAKE_JOBS} dist ${devnull}
cd "${old_pwd}"
......@@ -62,7 +62,7 @@ target_to_preproc_symbol() {
echo "__ARM_ARCH_6__"
;;
armv7-*)
echo "__ARM_ARCH_7__"
echo "__ARM_ARCH_7A__"
;;
armv7s-*)
echo "__ARM_ARCH_7S__"
......@@ -206,6 +206,10 @@ trap cleanup EXIT
# Parse the command line.
while [ -n "$1" ]; do
case "$1" in
--extra-configure-args)
EXTRA_CONFIGURE_ARGS="$2"
shift
;;
--help)
iosbuild_usage
exit
......@@ -235,6 +239,7 @@ if [ "${VERBOSE}" = "yes" ]; then
cat << EOF
BUILD_ROOT=${BUILD_ROOT}
DIST_DIR=${DIST_DIR}
EXTRA_CONFIGURE_ARGS=${EXTRA_CONFIGURE_ARGS}
FRAMEWORK_DIR=${FRAMEWORK_DIR}
HEADER_DIR=${HEADER_DIR}
MAKE_JOBS=${MAKE_JOBS}
......
......@@ -49,7 +49,7 @@ open CONFIG_FILE, $opts{config} or
my %config = ();
while (<CONFIG_FILE>) {
next if !/^CONFIG_/;
next if !/^(?:CONFIG_|HAVE_)/;
chomp;
my @pair = split /=/;
$config{$pair[0]} = $pair[1];
......@@ -209,14 +209,16 @@ sub common_top() {
#define RTCD_EXTERN extern
#endif
EOF
process_forward_decls();
print <<EOF;
#ifdef __cplusplus
extern "C" {
#endif
EOF
process_forward_decls();
print "\n";
declare_function_pointers("c", @ALL_ARCHS);
print <<EOF;
......@@ -365,13 +367,13 @@ if ($opts{arch} eq 'x86') {
@REQUIRES = filter(keys %required ? keys %required : qw/mmx sse sse2/);
&require(@REQUIRES);
x86;
} elsif ($opts{arch} eq 'mips32') {
@ALL_ARCHS = filter(qw/mips32/);
} elsif ($opts{arch} eq 'mips32' || $opts{arch} eq 'mips64') {
@ALL_ARCHS = filter("$opts{arch}");
open CONFIG_FILE, $opts{config} or
die "Error opening config file '$opts{config}': $!\n";
while (<CONFIG_FILE>) {
if (/HAVE_DSPR2=yes/) {
@ALL_ARCHS = filter(qw/mips32 dspr2/);
@ALL_ARCHS = filter("$opts{arch}", qw/dspr2/);
last;
}
}
......@@ -388,7 +390,7 @@ if ($opts{arch} eq 'x86') {
@REQUIRES = filter(keys %required ? keys %required : qw/media/);
&require(@REQUIRES);
arm;
} elsif ($opts{arch} eq 'armv8') {
} elsif ($opts{arch} eq 'armv8' || $opts{arch} eq 'arm64' ) {
@ALL_ARCHS = filter(qw/neon/);
arm;
} else {
......
......@@ -111,6 +111,7 @@ all_platforms="${all_platforms} armv7-win32-vs11"
all_platforms="${all_platforms} armv7-win32-vs12"
all_platforms="${all_platforms} armv7s-darwin-gcc"
all_platforms="${all_platforms} mips32-linux-gcc"
all_platforms="${all_platforms} mips64-linux-gcc"
all_platforms="${all_platforms} ppc32-darwin8-gcc"
all_platforms="${all_platforms} ppc32-darwin9-gcc"
all_platforms="${all_platforms} ppc32-linux-gcc"
......@@ -210,7 +211,6 @@ enable_feature spatial_resampling
enable_feature multithread
enable_feature os_support
enable_feature temporal_denoising
enable_feature high_quant
[ -d "${source_path}/../include" ] && enable_feature alt_tree_layout
for d in vp8 vp9; do
......@@ -255,6 +255,8 @@ ARCH_EXT_LIST="
mips32
dspr2
mips64
mmx
sse
sse2
......@@ -276,12 +278,10 @@ HAVE_LIST="
unistd_h
"
EXPERIMENT_LIST="
vp9_high
spatial_svc
high_quant
vp9_temporal_denoising
emulate_hw_high
fp_mb_stats
emulate_hardware
"
CONFIG_LIST="
external_build
......@@ -335,6 +335,7 @@ CONFIG_LIST="
multi_res_encoding
temporal_denoising
coefficient_range_checking
vp9_highbitdepth
experimental
size_limit
${EXPERIMENT_LIST}
......@@ -393,6 +394,7 @@ CMDLINE_SELECT="
multi_res_encoding
temporal_denoising
coefficient_range_checking
vp9_highbitdepth
experimental
"
......
......@@ -31,6 +31,7 @@ LIBYUV_SRCS += third_party/libyuv/include/libyuv/basic_types.h \
third_party/libyuv/source/scale_common.cc \
third_party/libyuv/source/scale_mips.cc \
third_party/libyuv/source/scale_neon.cc \
third_party/libyuv/source/scale_neon64.cc \
third_party/libyuv/source/scale_posix.cc \
third_party/libyuv/source/scale_win.cc \
......@@ -113,7 +114,7 @@ vpx_temporal_svc_encoder.SRCS += video_common.h
vpx_temporal_svc_encoder.SRCS += video_writer.h video_writer.c
vpx_temporal_svc_encoder.GUID = B18C08F2-A439-4502-A78E-849BE3D60947
vpx_temporal_svc_encoder.DESCRIPTION = Temporal SVC Encoder
EXAMPLES-$(CONFIG_VP8_DECODER) += simple_decoder.c
EXAMPLES-$(CONFIG_DECODERS) += simple_decoder.c
simple_decoder.GUID = D3BBF1E9-2427-450D-BBFF-B2843C1D44CC
simple_decoder.SRCS += ivfdec.h ivfdec.c
simple_decoder.SRCS += tools_common.h tools_common.c
......@@ -122,7 +123,7 @@ simple_decoder.SRCS += video_reader.h video_reader.c
simple_decoder.SRCS += vpx_ports/mem_ops.h
simple_decoder.SRCS += vpx_ports/mem_ops_aligned.h
simple_decoder.DESCRIPTION = Simplified decoder loop
EXAMPLES-$(CONFIG_VP8_DECODER) += postproc.c
EXAMPLES-$(CONFIG_DECODERS) += postproc.c
postproc.SRCS += ivfdec.h ivfdec.c
postproc.SRCS += tools_common.h tools_common.c
postproc.SRCS += video_common.h
......@@ -131,7 +132,7 @@ postproc.SRCS += vpx_ports/mem_ops.h
postproc.SRCS += vpx_ports/mem_ops_aligned.h
postproc.GUID = 65E33355-F35E-4088-884D-3FD4905881D7
postproc.DESCRIPTION = Decoder postprocessor control
EXAMPLES-$(CONFIG_VP8_DECODER) += decode_to_md5.c
EXAMPLES-$(CONFIG_DECODERS) += decode_to_md5.c
decode_to_md5.SRCS += md5_utils.h md5_utils.c
decode_to_md5.SRCS += ivfdec.h ivfdec.c
decode_to_md5.SRCS += tools_common.h tools_common.c
......@@ -141,29 +142,34 @@ decode_to_md5.SRCS += vpx_ports/mem_ops.h
decode_to_md5.SRCS += vpx_ports/mem_ops_aligned.h
decode_to_md5.GUID = 59120B9B-2735-4BFE-B022-146CA340FE42
decode_to_md5.DESCRIPTION = Frame by frame MD5 checksum
EXAMPLES-$(CONFIG_VP8_ENCODER) += simple_encoder.c
EXAMPLES-$(CONFIG_ENCODERS) += simple_encoder.c
simple_encoder.SRCS += ivfenc.h ivfenc.c
simple_encoder.SRCS += tools_common.h tools_common.c
simple_encoder.SRCS += video_common.h
simple_encoder.SRCS += video_writer.h video_writer.c
simple_encoder.GUID = 4607D299-8A71-4D2C-9B1D-071899B6FBFD
simple_encoder.DESCRIPTION = Simplified encoder loop
EXAMPLES-$(CONFIG_VP8_ENCODER) += twopass_encoder.c
EXAMPLES-$(CONFIG_VP9_ENCODER) += vp9_lossless_encoder.c
vp9_lossless_encoder.SRCS += ivfenc.h ivfenc.c
vp9_lossless_encoder.SRCS += tools_common.h tools_common.c
vp9_lossless_encoder.SRCS += video_common.h
vp9_lossless_encoder.SRCS += video_writer.h video_writer.c
vp9_lossless_encoder.GUID = B63C7C88-5348-46DC-A5A6-CC151EF93366
vp9_lossless_encoder.DESCRIPTION = Simplified lossless VP9 encoder
EXAMPLES-$(CONFIG_ENCODERS) += twopass_encoder.c
twopass_encoder.SRCS += ivfenc.h ivfenc.c
twopass_encoder.SRCS += tools_common.h tools_common.c
twopass_encoder.SRCS += video_common.h
twopass_encoder.SRCS += video_writer.h video_writer.c
twopass_encoder.GUID = 73494FA6-4AF9-4763-8FBB-265C92402FD8
twopass_encoder.DESCRIPTION = Two-pass encoder loop
ifeq ($(CONFIG_DECODERS),yes)
EXAMPLES-$(CONFIG_VP8_ENCODER) += decode_with_drops.c
EXAMPLES-$(CONFIG_DECODERS) += decode_with_drops.c
decode_with_drops.SRCS += ivfdec.h ivfdec.c
decode_with_drops.SRCS += tools_common.h tools_common.c
decode_with_drops.SRCS += video_common.h
decode_with_drops.SRCS += video_reader.h video_reader.c
decode_with_drops.SRCS += vpx_ports/mem_ops.h
decode_with_drops.SRCS += vpx_ports/mem_ops_aligned.h
endif
decode_with_drops.GUID = CE5C53C4-8DDA-438A-86ED-0DDD3CDB8D26
decode_with_drops.DESCRIPTION = Drops frames while decoding
EXAMPLES-$(CONFIG_ENCODERS) += set_maps.c
......@@ -185,7 +191,9 @@ vp8cx_set_ref.DESCRIPTION = VP8 set encoder reference frame
ifeq ($(CONFIG_MULTI_RES_ENCODING),yes)
ifeq ($(CONFIG_LIBYUV),yes)
EXAMPLES-$(CONFIG_VP8_ENCODER) += vp8_multi_resolution_encoder.c
vp8_multi_resolution_encoder.SRCS += ivfenc.h ivfenc.c
vp8_multi_resolution_encoder.SRCS += tools_common.h tools_common.c
vp8_multi_resolution_encoder.SRCS += video_writer.h video_writer.c
vp8_multi_resolution_encoder.SRCS += $(LIBYUV_SRCS)
vp8_multi_resolution_encoder.GUID = 04f8738e-63c8-423b-90fa-7c2703a374de
vp8_multi_resolution_encoder.DESCRIPTION = VP8 Multiple-resolution Encoding
......
......@@ -33,8 +33,6 @@
#include <stdlib.h>
#include <string.h>
#define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vp8dx.h"
#include "vpx/vpx_decoder.h"
......
......@@ -56,8 +56,6 @@
#include <stdlib.h>
#include <string.h>
#define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vp8dx.h"
#include "vpx/vpx_decoder.h"
......
......@@ -43,8 +43,6 @@
#include <stdlib.h>
#include <string.h>
#define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vp8dx.h"
#include "vpx/vpx_decoder.h"
......
......@@ -42,11 +42,11 @@
// Use the `simple_decoder` example to decode this sample, and observe
// the change in the image at frames 22, 33, and 44.
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h"
......@@ -125,10 +125,11 @@ static void unset_active_map(const vpx_codec_enc_cfg_t *cfg,
die_codec(codec, "Failed to set active map");
}
static void encode_frame(vpx_codec_ctx_t *codec,
vpx_image_t *img,
int frame_index,
VpxVideoWriter *writer) {
static int encode_frame(vpx_codec_ctx_t *codec,
vpx_image_t *img,
int frame_index,
VpxVideoWriter *writer) {
int got_pkts = 0;
vpx_codec_iter_t iter = NULL;
const vpx_codec_cx_pkt_t *pkt = NULL;
const vpx_codec_err_t res = vpx_codec_encode(codec, img, frame_index, 1, 0,
......@@ -137,6 +138,8 @@ static void encode_frame(vpx_codec_ctx_t *codec,
die_codec(codec, "Failed to encode frame");
while ((pkt = vpx_codec_get_cx_data(codec, &iter)) != NULL) {
got_pkts = 1;
if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
const int keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0;
if (!vpx_video_writer_write_frame(writer,
......@@ -150,6 +153,8 @@ static void encode_frame(vpx_codec_ctx_t *codec,
fflush(stdout);
}
}
return got_pkts;
}
int main(int argc, char **argv) {
......@@ -172,9 +177,10 @@ int main(int argc, char **argv) {
memset(&info, 0, sizeof(info));
encoder = get_vpx_encoder_by_name(argv[1]);
if (!encoder)
if (encoder == NULL) {
die("Unsupported codec.");
}
assert(encoder != NULL);
info.codec_fourcc = encoder->fourcc;
info.frame_width = strtol(argv[2], NULL, 0);
info.frame_height = strtol(argv[3], NULL, 0);
......@@ -217,6 +223,7 @@ int main(int argc, char **argv) {
if (vpx_codec_enc_init(&codec, encoder->codec_interface(), &cfg, 0))
die_codec(&codec, "Failed to initialize encoder");
// Encode frames.
while (vpx_img_read(&raw, infile)) {
++frame_count;
......@@ -230,7 +237,10 @@ int main(int argc, char **argv) {
encode_frame(&codec, &raw, frame_count, writer);
}
encode_frame(&codec, NULL, -1, writer);
// Flush encoder.
while (encode_frame(&codec, NULL, -1, writer)) {}
printf("\n");
fclose(infile);
printf("Processed %d frames.\n", frame_count);
......
......@@ -29,30 +29,29 @@
// -----------------
// For decoders, you only have to include `vpx_decoder.h` and then any
// header files for the specific codecs you use. In this case, we're using
// vp8. The `VPX_CODEC_DISABLE_COMPAT` macro can be defined to ensure
// strict compliance with the latest SDK by disabling some backwards
// compatibility features. Defining this macro is encouraged.
// vp8.
//
// Initializing The Codec
// ----------------------
// The decoder is initialized by the following code. This is an example for
// the VP8 decoder, but the code is analogous for all algorithms. Replace
// `vpx_codec_vp8_dx()` with a pointer to the interface exposed by the
// algorithm you want to use. The `cfg` argument is left as NULL in this
// example, because we want the algorithm to determine the stream
// configuration (width/height) and allocate memory automatically. This
// parameter is generally only used if you need to preallocate memory,
// particularly in External Memory Allocation mode.
// The libvpx decoder is initialized by the call to vpx_codec_dec_init().
// Determining the codec interface to use is handled by VpxVideoReader and the
// functions prefixed with vpx_video_reader_. Discussion of those functions is
// beyond the scope of this example, but the main gist is to open the input file
// and parse just enough of it to determine if it's a VPx file and which VPx
// codec is contained within the file.
// Note the NULL pointer passed to vpx_codec_dec_init(). We do that in this
// example because we want the algorithm to determine the stream configuration
// (width/height) and allocate memory automatically.
//
// Decoding A Frame
// ----------------
// Once the frame has been read into memory, it is decoded using the
// `vpx_codec_decode` function. The call takes a pointer to the data
// (`frame`) and the length of the data (`frame_sz`). No application data
// (`frame`) and the length of the data (`frame_size`). No application data
// is associated with the frame in this example, so the `user_priv`
// parameter is NULL. The `deadline` parameter is left at zero for this
// example. This parameter is generally only used when doing adaptive
// postprocessing.
// example. This parameter is generally only used when doing adaptive post
// processing.
//
// Codecs may produce a variable number of output frames for every call to
// `vpx_codec_decode`. These frames are retrieved by the
......@@ -74,16 +73,13 @@
// --------------
// This example does not special case any error return codes. If there was
// an error, a descriptive message is printed and the program exits. With
// few exeptions, vpx_codec functions return an enumerated error status,
// few exceptions, vpx_codec functions return an enumerated error status,
// with the value `0` indicating success.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vp8dx.h"
#include "vpx/vpx_decoder.h"
#include "./tools_common.h"
......
......@@ -28,9 +28,7 @@
// -----------------
// For encoders, you only have to include `vpx_encoder.h` and then any
// header files for the specific codecs you use. In this case, we're using
// vp8. The `VPX_CODEC_DISABLE_COMPAT` macro can be defined to ensure
// strict compliance with the latest SDK by disabling some backwards
// compatibility features. Defining this macro is encouraged.
// vp8.
//
// Getting The Default Configuration
// ---------------------------------
......@@ -101,7 +99,6 @@
#include <stdlib.h>
#include <string.h>
#define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vpx_encoder.h"
#include "./tools_common.h"
......@@ -243,7 +240,7 @@ int main(int argc, char **argv) {
}
// Flush encoder.
while (encode_frame(&codec, NULL, -1, 0, writer)) {}
while (encode_frame(&codec, NULL, -1, 0, writer)) {};
printf("\n");
fclose(infile);
......
......@@ -28,9 +28,8 @@
// Encoding A Frame
// ----------------
// Encoding a frame in two pass mode is identical to the simple encoder
// example, except the deadline is set to VPX_DL_BEST_QUALITY to get the
// best quality possible. VPX_DL_GOOD_QUALITY could also be used.
//
// example. To increase the quality while sacrificing encoding speed,
// VPX_DL_BEST_QUALITY can be used in place of VPX_DL_GOOD_QUALITY.
//
// Processing Statistics Packets
// -----------------------------
......@@ -52,7 +51,6 @@
#include <stdlib.h>
#include <string.h>
#define VPX_CODEC_DISABLE_COMPAT 1
#include "vpx/vpx_encoder.h"
#include "./tools_common.h"
......@@ -66,13 +64,14 @@ void usage_exit() {
exit(EXIT_FAILURE);
}
static void get_frame_stats(vpx_codec_ctx_t *ctx,
const vpx_image_t *img,
vpx_codec_pts_t pts,
unsigned int duration,
vpx_enc_frame_flags_t flags,
unsigned int deadline,
vpx_fixed_buf_t *stats) {
static int get_frame_stats(vpx_codec_ctx_t *ctx,
const vpx_image_t *img,
vpx_codec_pts_t pts,
unsigned int duration,
vpx_enc_frame_flags_t flags,
unsigned int deadline,
vpx_fixed_buf_t *stats) {
int got_pkts = 0;
vpx_codec_iter_t iter = NULL;
const vpx_codec_cx_pkt_t *pkt = NULL;
const vpx_codec_err_t res = vpx_codec_encode(ctx, img, pts, duration, flags,
......@@ -81,6 +80,8 @@ static void get_frame_stats(vpx_codec_ctx_t *ctx,
die_codec(ctx, "Failed to get frame stats.");
while ((pkt = vpx_codec_get_cx_data(ctx, &iter)) != NULL) {
got_pkts = 1;
if (pkt->kind == VPX_CODEC_STATS_PKT) {
const uint8_t *const pkt_buf = pkt->data.twopass_stats.buf;
const size_t pkt_size = pkt->data.twopass_stats.sz;
......@@ -89,15 +90,18 @@ static void get_frame_stats(vpx_codec_ctx_t *ctx,
stats->sz += pkt_size;
}
}
return got_pkts;
}
static void encode_frame(vpx_codec_ctx_t *ctx,
const vpx_image_t *img,
vpx_codec_pts_t pts,
unsigned int duration,
vpx_enc_frame_flags_t flags,
unsigned int deadline,
VpxVideoWriter *writer) {
static int encode_frame(vpx_codec_ctx_t *ctx,
const vpx_image_t *img,
vpx_codec_pts_t pts,
unsigned int duration,
vpx_enc_frame_flags_t flags,
unsigned int deadline,
VpxVideoWriter *writer) {
int got_pkts = 0;
vpx_codec_iter_t iter = NULL;
const vpx_codec_cx_pkt_t *pkt = NULL;
const vpx_codec_err_t res = vpx_codec_encode(ctx, img, pts, duration, flags,
......@@ -106,6 +110,7 @@ static void encode_frame(vpx_codec_ctx_t *ctx,
die_codec(ctx, "Failed to encode frame.");
while ((pkt = vpx_codec_get_cx_data(ctx, &iter)) != NULL) {
got_pkts = 1;
if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
const int keyframe = (pkt->data.frame.flags & VPX_FRAME_IS_KEY) != 0;
......@@ -117,19 +122,90 @@ static void encode_frame(vpx_codec_ctx_t *ctx,
fflush(stdout);
}
}
return got_pkts;
}
static vpx_fixed_buf_t pass0(vpx_image_t *raw,