# Running ndk-build will build libvpx and include it in your project.
#
+# Alternatively, building the examples and unit tests can be accomplished in the
+# following way:
+#
+# Create a standalone toolchain from the NDK:
+# https://developer.android.com/ndk/guides/standalone_toolchain.html
+#
+# For example - to test on arm64 devices with clang:
+# $NDK/build/tools/make_standalone_toolchain.py \
+# --arch arm64 --install-dir=/tmp/my-android-toolchain
+# export PATH=/tmp/my-android-toolchain/bin:$PATH
+# CROSS=aarch64-linux-android- CC=clang CXX=clang++ /path/to/libvpx/configure \
+# --target=arm64-android-gcc
+#
+# Push the resulting binaries to a device and run them:
+# adb push test_libvpx /data/tmp/test_libvpx
+# adb shell /data/tmp/test_libvpx --gtest_filter=\*Sixtap\*
+#
+# Make sure to push the test data as well and set LIBVPX_TEST_DATA
+
CONFIG_DIR := $(LOCAL_PATH)/
LIBVPX_PATH := $(LOCAL_PATH)/libvpx
ASM_CNV_PATH_LOCAL := $(TARGET_ARCH_ABI)/ads2gas
;;
android*)
- if [ -z "${sdk_path}" ]; then
- die "Must specify --sdk-path for Android builds."
- fi
-
- SDK_PATH=${sdk_path}
- COMPILER_LOCATION=`find "${SDK_PATH}" \
- -name "arm-linux-androideabi-gcc*" -print -quit`
- TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
- CC=${TOOLCHAIN_PATH}gcc
- CXX=${TOOLCHAIN_PATH}g++
- AR=${TOOLCHAIN_PATH}ar
- LD=${TOOLCHAIN_PATH}gcc
- AS=${TOOLCHAIN_PATH}as
- STRIP=${TOOLCHAIN_PATH}strip
- NM=${TOOLCHAIN_PATH}nm
-
- if [ -z "${alt_libc}" ]; then
- alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
- awk '{n = split($0,a,"/"); \
+ if [ -n "${sdk_path}" ]; then
+ SDK_PATH=${sdk_path}
+ COMPILER_LOCATION=`find "${SDK_PATH}" \
+ -name "arm-linux-androideabi-gcc*" -print -quit`
+ TOOLCHAIN_PATH=${COMPILER_LOCATION%/*}/arm-linux-androideabi-
+ CC=${TOOLCHAIN_PATH}gcc
+ CXX=${TOOLCHAIN_PATH}g++
+ AR=${TOOLCHAIN_PATH}ar
+ LD=${TOOLCHAIN_PATH}gcc
+ AS=${TOOLCHAIN_PATH}as
+ STRIP=${TOOLCHAIN_PATH}strip
+ NM=${TOOLCHAIN_PATH}nm
+
+ if [ -z "${alt_libc}" ]; then
+ alt_libc=`find "${SDK_PATH}" -name arch-arm -print | \
+ awk '{n = split($0,a,"/"); \
split(a[n-1],b,"-"); \
print $0 " " b[2]}' | \
sort -g -k 2 | \
awk '{ print $1 }' | tail -1`
- fi
+ fi
- if [ -d "${alt_libc}" ]; then
- add_cflags "--sysroot=${alt_libc}"
- add_ldflags "--sysroot=${alt_libc}"
- fi
+ if [ -d "${alt_libc}" ]; then
+ add_cflags "--sysroot=${alt_libc}"
+ add_ldflags "--sysroot=${alt_libc}"
+ fi
- # linker flag that routes around a CPU bug in some
- # Cortex-A8 implementations (NDK Dev Guide)
- add_ldflags "-Wl,--fix-cortex-a8"
+ # linker flag that routes around a CPU bug in some
+ # Cortex-A8 implementations (NDK Dev Guide)
+ add_ldflags "-Wl,--fix-cortex-a8"
- enable_feature pic
- soft_enable realtime_only
- if [ ${tgt_isa} = "armv7" ]; then
- soft_enable runtime_cpu_detect
- fi
- if enabled runtime_cpu_detect; then
- add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
+ enable_feature pic
+ soft_enable realtime_only
+ if [ ${tgt_isa} = "armv7" ]; then
+ soft_enable runtime_cpu_detect
+ fi
+ if enabled runtime_cpu_detect; then
+ add_cflags "-I${SDK_PATH}/sources/android/cpufeatures"
+ fi
+ else
+ echo "Assuming standalone build with NDK toolchain."
+ echo "See build/make/Android.mk for details."
+ check_add_ldflags -static
+ soft_enable unit_tests
fi
;;
*-win*-vs*)
;;
*-android-gcc)
+ # bionic includes basic pthread functionality, obviating -lpthread.
;;
*)
check_header pthread.h && add_extralibs -lpthread
# all_platforms is a list of all supported target platforms. Maintain
# alphabetically by architecture, generic-gnu last.
+all_platforms="${all_platforms} arm64-android-gcc"
all_platforms="${all_platforms} arm64-darwin-gcc"
all_platforms="${all_platforms} arm64-linux-gcc"
all_platforms="${all_platforms} armv7-android-gcc" #neon Cortex-A8
int frame_count = 0;
vpx_image_t raw;
vpx_codec_err_t res;
- VpxVideoInfo info = { 0 };
+ VpxVideoInfo info = { 0, 0, 0, { 0, 0 } };
VpxVideoWriter *writer = NULL;
const VpxInterface *encoder = NULL;
const int fps = 30;
#include "vpx/vp8cx.h"
#include "vpx/vpx_encoder.h"
+#include "vp8/common/common.h"
#include "../tools_common.h"
#include "../video_writer.h"
int main(int argc, char **argv) {
FILE *infile = NULL;
- vpx_codec_ctx_t codec = { 0 };
- vpx_codec_enc_cfg_t cfg = { 0 };
+ vpx_codec_ctx_t codec;
+ vpx_codec_enc_cfg_t cfg;
int frame_count = 0;
vpx_image_t raw;
vpx_codec_err_t res;
- VpxVideoInfo info = { 0 };
+ VpxVideoInfo info;
VpxVideoWriter *writer = NULL;
const VpxInterface *encoder = NULL;
int update_frame_num = 0;
const int fps = 30; // TODO(dkovalev) add command line argument
const int bitrate = 200; // kbit/s TODO(dkovalev) add command line argument
+ vp8_zero(codec);
+ vp8_zero(cfg);
+ vp8_zero(info);
+
exec_name = argv[0];
if (argc != 6) die("Invalid number of arguments");
#include "vpx/vpx_encoder.h"
#include "vpx/vp8cx.h"
+#include "vp9/common/vp9_common.h"
#include "../tools_common.h"
#include "../video_writer.h"
int frame_count = 0;
vpx_image_t raw;
vpx_codec_err_t res;
- VpxVideoInfo info = { 0 };
+ VpxVideoInfo info;
VpxVideoWriter *writer = NULL;
const VpxInterface *encoder = NULL;
const int fps = 30;
+ vp9_zero(info);
+
exec_name = argv[0];
if (argc < 5) die("Invalid number of arguments");
#include "vpx/vp8cx.h"
#include "vpx/vpx_decoder.h"
#include "vpx/vpx_encoder.h"
+#include "vp9/common/vp9_common.h"
#include "./tools_common.h"
#include "./video_writer.h"
}
static void testing_decode(vpx_codec_ctx_t *encoder, vpx_codec_ctx_t *decoder,
- vpx_codec_enc_cfg_t *cfg, unsigned int frame_out,
- int *mismatch_seen) {
+ unsigned int frame_out, int *mismatch_seen) {
vpx_image_t enc_img, dec_img;
struct vp9_ref_frame ref_enc, ref_dec;
vpx_img_free(&dec_img);
}
-static int encode_frame(vpx_codec_ctx_t *ecodec, vpx_codec_enc_cfg_t *cfg,
- vpx_image_t *img, unsigned int frame_in,
- VpxVideoWriter *writer, int test_decode,
- vpx_codec_ctx_t *dcodec, unsigned int *frame_out,
- int *mismatch_seen) {
+static int encode_frame(vpx_codec_ctx_t *ecodec, vpx_image_t *img,
+ unsigned int frame_in, VpxVideoWriter *writer,
+ int test_decode, vpx_codec_ctx_t *dcodec,
+ unsigned int *frame_out, int *mismatch_seen) {
int got_pkts = 0;
vpx_codec_iter_t iter = NULL;
const vpx_codec_cx_pkt_t *pkt = NULL;
// Mismatch checking
if (got_data && test_decode) {
- testing_decode(ecodec, dcodec, cfg, *frame_out, mismatch_seen);
+ testing_decode(ecodec, dcodec, *frame_out, mismatch_seen);
}
return got_pkts;
int main(int argc, char **argv) {
FILE *infile = NULL;
// Encoder
- vpx_codec_ctx_t ecodec = { 0 };
- vpx_codec_enc_cfg_t cfg = { 0 };
+ vpx_codec_ctx_t ecodec;
+ vpx_codec_enc_cfg_t cfg;
unsigned int frame_in = 0;
vpx_image_t raw;
vpx_codec_err_t res;
- VpxVideoInfo info = { 0 };
+ VpxVideoInfo info;
VpxVideoWriter *writer = NULL;
const VpxInterface *encoder = NULL;
const char *infile_arg = NULL;
const char *outfile_arg = NULL;
unsigned int limit = 0;
+
+ vp9_zero(ecodec);
+ vp9_zero(cfg);
+ vp9_zero(info);
+
exec_name = argv[0];
if (argc < 6) die("Invalid number of arguments");
}
}
- encode_frame(&ecodec, &cfg, &raw, frame_in, writer, test_decode, &dcodec,
+ encode_frame(&ecodec, &raw, frame_in, writer, test_decode, &dcodec,
&frame_out, &mismatch_seen);
frame_in++;
if (mismatch_seen) break;
// Flush encoder.
if (!mismatch_seen)
- while (encode_frame(&ecodec, &cfg, NULL, frame_in, writer, test_decode,
- &dcodec, &frame_out, &mismatch_seen)) {
+ while (encode_frame(&ecodec, NULL, frame_in, writer, test_decode, &dcodec,
+ &frame_out, &mismatch_seen)) {
}
printf("\n");
SetMode(libvpx_test::kTwoPassGood);
}
- virtual void BeginPassHook(unsigned int pass) { altref_count_ = 0; }
+ virtual void BeginPassHook(unsigned int /*pass*/) { altref_count_ = 0; }
virtual void PreEncodeFrameHook(libvpx_test::VideoSource *video,
libvpx_test::Encoder *encoder) {
TEST_P(InvalidFileInvalidPeekTest, ReturnCode) { RunTest(); }
+#if CONFIG_VP8_DECODER
const DecodeParam kVP8InvalidFileTests[] = {
{ 1, "invalid-vp80-00-comprehensive-018.ivf.2kf_0x6.ivf" },
};
VP8_INSTANTIATE_TEST_CASE(InvalidFileInvalidPeekTest,
::testing::ValuesIn(kVP8InvalidFileTests));
+#endif // CONFIG_VP8_DECODER
+#if CONFIG_VP9_DECODER
const DecodeParam kVP9InvalidFileInvalidPeekTests[] = {
{ 1, "invalid-vp90-01-v3.webm" },
};
VP9_INSTANTIATE_TEST_CASE(InvalidFileInvalidPeekTest,
::testing::ValuesIn(kVP9InvalidFileInvalidPeekTests));
-#if CONFIG_VP9_DECODER
const DecodeParam kMultiThreadedVP9InvalidFileTests[] = {
{ 4, "invalid-vp90-2-08-tile_1x4_frame_parallel_all_key.webm" },
{ 4,
int in_frames = 0;
int out_frames = 0;
- vpx_codec_dec_cfg_t cfg = { 0 };
+ vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
cfg.threads = num_threads;
vpx_codec_flags_t flags = 0;
flags |= VPX_CODEC_USE_FRAME_THREADING;
*/
#include <arm_neon.h>
+#include <string.h>
+#include "./vpx_config.h"
static const uint8_t bifilter4_coeff[8][2] = { { 128, 0 }, { 112, 16 },
{ 96, 32 }, { 80, 48 },
{ 64, 64 }, { 48, 80 },
{ 32, 96 }, { 16, 112 } };
+static INLINE uint8x8_t load_and_shift(const unsigned char *a) {
+ return vreinterpret_u8_u64(vshl_n_u64(vreinterpret_u64_u8(vld1_u8(a)), 32));
+}
+
+static INLINE void store4x4(unsigned char *dst, int dst_stride,
+ const uint8x8_t a0, const uint8x8_t a1) {
+ if (!((uintptr_t)dst & 0x3) && !(dst_stride & 0x3)) {
+ vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(a0), 0);
+ dst += dst_stride;
+ vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(a0), 1);
+ dst += dst_stride;
+ vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(a1), 0);
+ dst += dst_stride;
+ vst1_lane_u32((uint32_t *)dst, vreinterpret_u32_u8(a1), 1);
+ } else {
+ // Store to the aligned local buffer and memcpy instead of vget_lane_u8
+ // which is really really slow.
+ uint32_t output_buffer[4];
+ vst1_lane_u32(output_buffer, vreinterpret_u32_u8(a0), 0);
+ vst1_lane_u32(output_buffer + 1, vreinterpret_u32_u8(a0), 1);
+ vst1_lane_u32(output_buffer + 2, vreinterpret_u32_u8(a1), 0);
+ vst1_lane_u32(output_buffer + 3, vreinterpret_u32_u8(a1), 1);
+
+ memcpy(dst, output_buffer, 4);
+ dst += dst_stride;
+ memcpy(dst, output_buffer + 1, 4);
+ dst += dst_stride;
+ memcpy(dst, output_buffer + 2, 4);
+ dst += dst_stride;
+ memcpy(dst, output_buffer + 3, 4);
+ }
+}
+
+void vp8_bilinear_predict4x4_neon(unsigned char *src_ptr,
+ int src_pixels_per_line, int xoffset,
+ int yoffset, unsigned char *dst_ptr,
+ int dst_pitch) {
+ uint8x8_t e0, e1, e2;
+
+ if (xoffset == 0) { // skip_1stpass_filter
+ uint8x8_t a0, a1, a2, a3, a4;
+
+ a0 = load_and_shift(src_ptr);
+ src_ptr += src_pixels_per_line;
+ a1 = vld1_u8(src_ptr);
+ src_ptr += src_pixels_per_line;
+ a2 = load_and_shift(src_ptr);
+ src_ptr += src_pixels_per_line;
+ a3 = vld1_u8(src_ptr);
+ src_ptr += src_pixels_per_line;
+ a4 = vld1_u8(src_ptr);
+
+ e0 = vext_u8(a0, a1, 4);
+ e1 = vext_u8(a2, a3, 4);
+ e2 = a4;
+ } else {
+ uint8x8_t a0, a1, a2, a3, a4, b4;
+ uint8x16_t a01, a23;
+ uint8x16_t b01, b23;
+ uint32x2x2_t c0, c1, c2, c3;
+ uint16x8_t d0, d1, d2;
+ const uint8x8_t filter0 = vdup_n_u8(bifilter4_coeff[xoffset][0]);
+ const uint8x8_t filter1 = vdup_n_u8(bifilter4_coeff[xoffset][1]);
+
+ a0 = vld1_u8(src_ptr);
+ src_ptr += src_pixels_per_line;
+ a1 = vld1_u8(src_ptr);
+ src_ptr += src_pixels_per_line;
+ a2 = vld1_u8(src_ptr);
+ src_ptr += src_pixels_per_line;
+ a3 = vld1_u8(src_ptr);
+ src_ptr += src_pixels_per_line;
+ a4 = vld1_u8(src_ptr);
+
+ a01 = vcombine_u8(a0, a1);
+ a23 = vcombine_u8(a2, a3);
+
+ b01 = vreinterpretq_u8_u64(vshrq_n_u64(vreinterpretq_u64_u8(a01), 8));
+ b23 = vreinterpretq_u8_u64(vshrq_n_u64(vreinterpretq_u64_u8(a23), 8));
+ b4 = vreinterpret_u8_u64(vshr_n_u64(vreinterpret_u64_u8(a4), 8));
+
+ c0 = vzip_u32(vreinterpret_u32_u8(vget_low_u8(a01)),
+ vreinterpret_u32_u8(vget_high_u8(a01)));
+ c1 = vzip_u32(vreinterpret_u32_u8(vget_low_u8(a23)),
+ vreinterpret_u32_u8(vget_high_u8(a23)));
+ c2 = vzip_u32(vreinterpret_u32_u8(vget_low_u8(b01)),
+ vreinterpret_u32_u8(vget_high_u8(b01)));
+ c3 = vzip_u32(vreinterpret_u32_u8(vget_low_u8(b23)),
+ vreinterpret_u32_u8(vget_high_u8(b23)));
+
+ d0 = vmull_u8(vreinterpret_u8_u32(c0.val[0]), filter0);
+ d1 = vmull_u8(vreinterpret_u8_u32(c1.val[0]), filter0);
+ d2 = vmull_u8(a4, filter0);
+
+ d0 = vmlal_u8(d0, vreinterpret_u8_u32(c2.val[0]), filter1);
+ d1 = vmlal_u8(d1, vreinterpret_u8_u32(c3.val[0]), filter1);
+ d2 = vmlal_u8(d2, b4, filter1);
+
+ e0 = vqrshrn_n_u16(d0, 7);
+ e1 = vqrshrn_n_u16(d1, 7);
+ e2 = vqrshrn_n_u16(d2, 7);
+ }
+
+ // secondpass_filter
+ if (yoffset == 0) { // skip_2ndpass_filter
+ store4x4(dst_ptr, dst_pitch, e0, e1);
+ } else {
+ uint8x8_t f0, f1;
+ const uint8x8_t filter0 = vdup_n_u8(bifilter4_coeff[yoffset][0]);
+ const uint8x8_t filter1 = vdup_n_u8(bifilter4_coeff[yoffset][1]);
+
+ uint16x8_t b0 = vmull_u8(e0, filter0);
+ uint16x8_t b1 = vmull_u8(e1, filter0);
+
+ const uint8x8_t a0 = vext_u8(e0, e1, 4);
+ const uint8x8_t a1 = vext_u8(e1, e2, 4);
+
+ b0 = vmlal_u8(b0, a0, filter1);
+ b1 = vmlal_u8(b1, a1, filter1);
+
+ f0 = vqrshrn_n_u16(b0, 7);
+ f1 = vqrshrn_n_u16(b1, 7);
+
+ store4x4(dst_ptr, dst_pitch, f0, f1);
+ }
+}
+
void vp8_bilinear_predict8x4_neon(unsigned char *src_ptr,
int src_pixels_per_line, int xoffset,
int yoffset, unsigned char *dst_ptr,
};
const vp8_mbsplit vp8_mbsplits[VP8_NUMMBSPLITS] = {
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
- },
- {
- 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1,
- },
- {
- 0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3,
- },
- {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
- }
+ { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1 },
+ { 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1 },
+ { 0, 0, 1, 1, 0, 0, 1, 1, 2, 2, 3, 3, 2, 2, 3, 3 },
+ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }
};
const int vp8_mbsplit_count[VP8_NUMMBSPLITS] = { 2, 2, 4, 16 };
#if HAVE_UNISTD_H && !defined(__OS2__)
#if defined(_SC_NPROCESSORS_ONLN)
- core_count = sysconf(_SC_NPROCESSORS_ONLN);
+ core_count = (int)sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(_SC_NPROC_ONLN)
- core_count = sysconf(_SC_NPROC_ONLN);
+ core_count = (int)sysconf(_SC_NPROC_ONLN);
#endif
#elif defined(_WIN32)
{
GetSystemInfo(&sysinfo);
#endif
- core_count = sysinfo.dwNumberOfProcessors;
+ core_count = (int)sysinfo.dwNumberOfProcessors;
}
#elif defined(__OS2__)
{
RECON_CLAMP_NOTREQUIRED = 1
} CLAMP_TYPE;
-typedef struct VP8Common
-
- {
+typedef struct VP8Common {
struct vpx_internal_error_info error;
DECLARE_ALIGNED(16, short, Y1dequant[QINDEX_RANGE][2]);
const int pitch);
/***********************************************************************************************************
*/
+#if CONFIG_POSTPROC
static int q2mbl(int x) {
if (x < 20) x = 20;
return x * x / 3;
}
-#if CONFIG_POSTPROC
static void vp8_de_mblock(YV12_BUFFER_CONFIG *post, int q) {
vpx_mbpost_proc_across_ip(post->y_buffer, post->y_stride, post->y_height,
post->y_width, q2mbl(q));
vp8_yv12_copy_frame(source, post);
}
}
-#endif
void vp8_de_noise(VP8_COMMON *cm, YV12_BUFFER_CONFIG *source,
YV12_BUFFER_CONFIG *post, int q, int low_var_thresh, int flag,
}
}
}
+#endif // CONFIG_POSTPROC
/* Blend the macro block with a solid colored square. Leave the
* edges unblended to give distinction to macro blocks in areas
add_proto qw/void vp8_bilinear_predict8x4/, "unsigned char *src, int src_pitch, int xofst, int yofst, unsigned char *dst, int dst_pitch";
specialize qw/vp8_bilinear_predict8x4 mmx neon msa/;
-# TODO(johannkoenig): Add neon implementation
-# https://bugs.chromium.org/p/webm/issues/detail?id=1273
add_proto qw/void vp8_bilinear_predict4x4/, "unsigned char *src, int src_pitch, int xofst, int yofst, unsigned char *dst, int dst_pitch";
-specialize qw/vp8_bilinear_predict4x4 mmx msa/;
+specialize qw/vp8_bilinear_predict4x4 mmx neon msa/;
#
# Encoder functions below this point.
}
pbi->allocated_decoding_thread_count = ithread;
- if (pbi->allocated_decoding_thread_count != pbi->decoding_thread_count) {
+ if (pbi->allocated_decoding_thread_count !=
+ (int)pbi->decoding_thread_count) {
/* the remainder of cleanup cases will be handled in
* vp8_decoder_remove_threads(). */
if (pbi->allocated_decoding_thread_count == 0) {
xd->mode_info_stride * cpi->encoding_thread_count;
x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count;
x->gf_active_ptr += cm->mb_cols * cpi->encoding_thread_count;
-
- if (mb_row == cm->mb_rows - 1) {
- sem_post(&cpi->h_event_end_encoding); /* signal frame encoding end */
- }
}
-
- sem_wait(
- &cpi->h_event_end_encoding); /* wait for other threads to finish */
+ /* Wait for all the threads to finish. */
+ for (i = 0; i < cpi->encoding_thread_count; ++i) {
+ sem_wait(&cpi->h_event_end_encoding[i]);
+ }
for (mb_row = 0; mb_row < cm->mb_rows; ++mb_row) {
cpi->tok_count += (unsigned int)(cpi->tplist[mb_row].stop -
xd->mode_info_stride * cpi->encoding_thread_count;
x->partition_info += xd->mode_info_stride * cpi->encoding_thread_count;
x->gf_active_ptr += cm->mb_cols * cpi->encoding_thread_count;
-
- if (mb_row == cm->mb_rows - 1) {
- sem_post(&cpi->h_event_end_encoding); /* signal frame encoding end */
- }
}
+ /* Signal that this thread has completed processing its rows. */
+ sem_post(&cpi->h_event_end_encoding[ithread]);
}
}
vpx_malloc(sizeof(pthread_t) * th_count));
CHECK_MEM_ERROR(cpi->h_event_start_encoding,
vpx_malloc(sizeof(sem_t) * th_count));
+ CHECK_MEM_ERROR(cpi->h_event_end_encoding,
+ vpx_malloc(sizeof(sem_t) * th_count));
CHECK_MEM_ERROR(cpi->mb_row_ei,
vpx_memalign(32, sizeof(MB_ROW_COMP) * th_count));
memset(cpi->mb_row_ei, 0, sizeof(MB_ROW_COMP) * th_count);
CHECK_MEM_ERROR(cpi->en_thread_data,
vpx_malloc(sizeof(ENCODETHREAD_DATA) * th_count));
- sem_init(&cpi->h_event_end_encoding, 0, 0);
-
cpi->b_multi_threaded = 1;
cpi->encoding_thread_count = th_count;
vp8_setup_block_dptrs(&cpi->mb_row_ei[ithread].mb.e_mbd);
sem_init(&cpi->h_event_start_encoding[ithread], 0, 0);
+ sem_init(&cpi->h_event_end_encoding[ithread], 0, 0);
ethd->ithread = ithread;
ethd->ptr1 = (void *)cpi;
for (--ithread; ithread >= 0; ithread--) {
pthread_join(cpi->h_encoding_thread[ithread], 0);
sem_destroy(&cpi->h_event_start_encoding[ithread]);
+ sem_destroy(&cpi->h_event_end_encoding[ithread]);
}
- sem_destroy(&cpi->h_event_end_encoding);
/* free thread related resources */
vpx_free(cpi->h_event_start_encoding);
+ vpx_free(cpi->h_event_end_encoding);
vpx_free(cpi->h_encoding_thread);
vpx_free(cpi->mb_row_ei);
vpx_free(cpi->en_thread_data);
cpi->b_multi_threaded = 0;
for (--ithread; ithread >= 0; ithread--) {
sem_post(&cpi->h_event_start_encoding[ithread]);
+ sem_post(&cpi->h_event_end_encoding[ithread]);
pthread_join(cpi->h_encoding_thread[ithread], 0);
sem_destroy(&cpi->h_event_start_encoding[ithread]);
+ sem_destroy(&cpi->h_event_end_encoding[ithread]);
}
- sem_destroy(&cpi->h_event_end_encoding);
sem_destroy(&cpi->h_event_end_lpf);
sem_destroy(&cpi->h_event_start_lpf);
/* free thread related resources */
vpx_free(cpi->h_event_start_encoding);
+ vpx_free(cpi->h_event_end_encoding);
vpx_free(cpi->h_encoding_thread);
vpx_free(cpi->mb_row_ei);
vpx_free(cpi->en_thread_data);
for (i = 0; i < cpi->encoding_thread_count; ++i) {
sem_post(&cpi->h_event_start_encoding[i]);
+ sem_post(&cpi->h_event_end_encoding[i]);
+
pthread_join(cpi->h_encoding_thread[i], 0);
sem_destroy(&cpi->h_event_start_encoding[i]);
+ sem_destroy(&cpi->h_event_end_encoding[i]);
}
sem_post(&cpi->h_event_start_lpf);
pthread_join(cpi->h_filter_thread, 0);
}
- sem_destroy(&cpi->h_event_end_encoding);
sem_destroy(&cpi->h_event_end_lpf);
sem_destroy(&cpi->h_event_start_lpf);
/* free thread related resources */
vpx_free(cpi->h_event_start_encoding);
+ vpx_free(cpi->h_event_end_encoding);
vpx_free(cpi->h_encoding_thread);
vpx_free(cpi->mb_row_ei);
vpx_free(cpi->en_thread_data);
/* events */
sem_t *h_event_start_encoding;
- sem_t h_event_end_encoding;
+ sem_t *h_event_end_encoding;
sem_t h_event_start_lpf;
sem_t h_event_end_lpf;
#endif
extern unsigned int cnt_pm;
#endif
-#define MODEL_MODE 0
+#define MODEL_MODE 1
extern const int vp8_ref_frame_order[MAX_MODES];
extern const MB_PREDICTION_MODE vp8_mode_order[MAX_MODES];
}
static vpx_codec_err_t set_reference_and_update(vpx_codec_alg_priv_t *ctx,
- int flags) {
+ vpx_enc_frame_flags_t flags) {
/* Handle Flags */
if (((flags & VP8_EFLAG_NO_UPD_GF) && (flags & VP8_EFLAG_FORCE_GF)) ||
((flags & VP8_EFLAG_NO_UPD_ARF) && (flags & VP8_EFLAG_FORCE_ARF))) {
SNPRINT2(results, "\t%7.3f", cpi->worst_consistency);
}
- SNPRINT(headings, "\tTime\tRcErr\tAbsErr");
- SNPRINT2(results, "\t%7.3f", total_encode_time);
- SNPRINT2(results, "\t%7.3f", rate_err);
- SNPRINT2(results, "\t%7.3f", fabs(rate_err));
+ fprintf(f, "%s\t Time\tRcErr\tAbsErr\n", headings);
+ fprintf(f, "%s\t%8.0f\t%7.2f\t%7.2f\n", results, total_encode_time,
+ rate_err, fabs(rate_err));
}
fclose(f);
#define FRAME_OVERHEAD_BITS 200
-#define LIMIT_QP_ONEPASS_VBR_LAG 0
-
#if CONFIG_VP9_HIGHBITDEPTH
#define ASSIGN_MINQ_TABLE(bit_depth, name) \
do { \
active_worst_quality =
clamp(active_worst_quality, active_best_quality, rc->worst_quality);
-#if LIMIT_QP_ONEPASS_VBR_LAG
- if (oxcf->lag_in_frames > 0 && oxcf->rc_mode == VPX_VBR) {
- if (rc->force_qpmin > 0 && active_best_quality < rc->force_qpmin)
- active_best_quality =
- clamp(active_best_quality, rc->force_qpmin, rc->worst_quality);
- }
-#endif
-
*top_index = active_worst_quality;
*bottom_index = active_best_quality;
}
target = calc_pframe_target_size_one_pass_vbr(cpi);
vp9_rc_set_frame_target(cpi, target);
-#if LIMIT_QP_ONEPASS_VBR_LAG
- if (rc->avg_frame_low_motion > 85 &&
- avg_source_sad_lag < (sad_thresh1 >> 1))
- rc->force_qpmin = 48;
- else
- rc->force_qpmin = 0;
-#endif
}
rc->prev_avg_source_sad_lag = avg_source_sad_lag;
}
specialize qw/vpx_highbd_idct32x32_34_add/;
add_proto qw/void vpx_highbd_idct32x32_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
- specialize qw/vpx_highbd_idct32x32_1_add/;
+ specialize qw/vpx_highbd_idct32x32_1_add sse2/;
add_proto qw/void vpx_highbd_iwht4x4_1_add/, "const tran_low_t *input, uint8_t *dest, int dest_stride, int bd";
specialize qw/vpx_highbd_iwht4x4_1_add/;
}
}
}
+
+void vpx_highbd_idct32x32_1_add_sse2(const tran_low_t *input, uint8_t *dest8,
+ int stride, int bd) {
+ __m128i dc_value, d;
+ const __m128i zero = _mm_setzero_si128();
+ const __m128i one = _mm_set1_epi16(1);
+ const __m128i max = _mm_subs_epi16(_mm_slli_epi16(one, bd), one);
+ int a, i, j;
+ uint16_t *dest = CONVERT_TO_SHORTPTR(dest8);
+ tran_low_t out;
+
+ out = highbd_dct_const_round_shift(input[0] * cospi_16_64);
+ out = highbd_dct_const_round_shift(out * cospi_16_64);
+ a = ROUND_POWER_OF_TWO(out, 6);
+
+ d = _mm_set1_epi32(a);
+ dc_value = _mm_packs_epi32(d, d);
+ for (i = 0; i < 32; ++i) {
+ for (j = 0; j < 4; ++j) {
+ d = _mm_loadu_si128((const __m128i *)(&dest[j * 8]));
+ d = _mm_adds_epi16(d, dc_value);
+ d = _mm_max_epi16(d, zero);
+ d = _mm_min_epi16(d, max);
+ _mm_storeu_si128((__m128i *)(&dest[j * 8]), d);
+ }
+ dest += stride;
+ }
+}
#endif // CONFIG_VP9_HIGHBITDEPTH
return 1;
}
-static INLINE size_t *get_malloc_address_location(void *const mem) {
+static size_t *get_malloc_address_location(void *const mem) {
return ((size_t *)mem) - 1;
}
-static INLINE uint64_t get_aligned_malloc_size(size_t size, size_t align) {
+static uint64_t get_aligned_malloc_size(size_t size, size_t align) {
return (uint64_t)size + align - 1 + ADDRESS_STORAGE_SIZE;
}
-static INLINE void set_actual_malloc_address(void *const mem,
- const void *const malloc_addr) {
+static void set_actual_malloc_address(void *const mem,
+ const void *const malloc_addr) {
size_t *const malloc_addr_location = get_malloc_address_location(mem);
*malloc_addr_location = (size_t)malloc_addr;
}
-static INLINE void *get_actual_malloc_address(void *const mem) {
+static void *get_actual_malloc_address(void *const mem) {
size_t *const malloc_addr_location = get_malloc_address_location(mem);
return (void *)(*malloc_addr_location);
}
unsigned int output_bit_depth = 0;
#endif
#if CONFIG_VP8_DECODER
- vp8_postproc_cfg_t vp8_pp_cfg = { 0 };
+ vp8_postproc_cfg_t vp8_pp_cfg = { 0, 0, 0 };
int vp8_dbg_color_ref_frame = 0;
int vp8_dbg_color_mb_modes = 0;
int vp8_dbg_color_b_modes = 0;
#if CONFIG_WEBM_IO
if (stream->config.write_webm) {
stream->webm_ctx.stream = stream->file;
- write_webm_file_header(&stream->webm_ctx, cfg, &global->framerate,
- stream->config.stereo_fmt, global->codec->fourcc,
- pixel_aspect_ratio);
+ write_webm_file_header(&stream->webm_ctx, cfg, stream->config.stereo_fmt,
+ global->codec->fourcc, pixel_aspect_ratio);
}
#else
(void)pixel_aspect_ratio;
void write_webm_file_header(struct WebmOutputContext *webm_ctx,
const vpx_codec_enc_cfg_t *cfg,
- const struct vpx_rational *fps,
stereo_format_t stereo_fmt, unsigned int fourcc,
const struct VpxRational *par) {
mkvmuxer::MkvWriter *const writer = new mkvmuxer::MkvWriter(webm_ctx->stream);
void write_webm_file_header(struct WebmOutputContext *webm_ctx,
const vpx_codec_enc_cfg_t *cfg,
- const struct vpx_rational *fps,
stereo_format_t stereo_fmt, unsigned int fourcc,
const struct VpxRational *par);