Merge branch 'master' into nextgenv2
This commit is contained in:
Коммит
48b2713553
|
@ -611,7 +611,11 @@ process_toolchain() {
|
||||||
;;
|
;;
|
||||||
*) check_add_cflags -Wunused-but-set-variable ;;
|
*) check_add_cflags -Wunused-but-set-variable ;;
|
||||||
esac
|
esac
|
||||||
enabled extra_warnings || check_add_cflags -Wno-unused-function
|
if enabled mips || [ -z "${INLINE}" ]; then
|
||||||
|
enabled extra_warnings || check_add_cflags -Wno-unused-function
|
||||||
|
else
|
||||||
|
check_add_cflags -Wunused-function
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if enabled icc; then
|
if enabled icc; then
|
||||||
|
|
|
@ -21,14 +21,14 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
#if CONFIG_WEBM_IO
|
||||||
|
|
||||||
const int kLegacyByteAlignment = 0;
|
const int kLegacyByteAlignment = 0;
|
||||||
const int kLegacyYPlaneByteAlignment = 32;
|
const int kLegacyYPlaneByteAlignment = 32;
|
||||||
const int kNumPlanesToCheck = 3;
|
const int kNumPlanesToCheck = 3;
|
||||||
const char kVP9TestFile[] = "vp90-2-02-size-lf-1920x1080.webm";
|
const char kVP9TestFile[] = "vp90-2-02-size-lf-1920x1080.webm";
|
||||||
const char kVP9Md5File[] = "vp90-2-02-size-lf-1920x1080.webm.md5";
|
const char kVP9Md5File[] = "vp90-2-02-size-lf-1920x1080.webm.md5";
|
||||||
|
|
||||||
#if CONFIG_WEBM_IO
|
|
||||||
|
|
||||||
struct ByteAlignmentTestParam {
|
struct ByteAlignmentTestParam {
|
||||||
int byte_alignment;
|
int byte_alignment;
|
||||||
vpx_codec_err_t expected_value;
|
vpx_codec_err_t expected_value;
|
||||||
|
|
|
@ -293,6 +293,7 @@ void iht16x16_12(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
|
||||||
vp9_highbd_iht16x16_256_add_c(in, out, stride, tx_type, 12);
|
vp9_highbd_iht16x16_256_add_c(in, out, stride, tx_type, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_SSE2
|
||||||
void idct16x16_10_add_10_c(const tran_low_t *in, uint8_t *out, int stride) {
|
void idct16x16_10_add_10_c(const tran_low_t *in, uint8_t *out, int stride) {
|
||||||
vpx_highbd_idct16x16_10_add_c(in, out, stride, 10);
|
vpx_highbd_idct16x16_10_add_c(in, out, stride, 10);
|
||||||
}
|
}
|
||||||
|
@ -301,7 +302,6 @@ void idct16x16_10_add_12_c(const tran_low_t *in, uint8_t *out, int stride) {
|
||||||
vpx_highbd_idct16x16_10_add_c(in, out, stride, 12);
|
vpx_highbd_idct16x16_10_add_c(in, out, stride, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_SSE2
|
|
||||||
void idct16x16_256_add_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
|
void idct16x16_256_add_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
|
||||||
vpx_highbd_idct16x16_256_add_sse2(in, out, stride, 10);
|
vpx_highbd_idct16x16_256_add_sse2(in, out, stride, 10);
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,10 +81,6 @@ typedef std::tr1::tuple<FwdTxfmFunc, InvTxfmFunc, int, vpx_bit_depth_t>
|
||||||
Trans32x32Param;
|
Trans32x32Param;
|
||||||
|
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
#if CONFIG_VP9_HIGHBITDEPTH
|
||||||
void idct32x32_8(const tran_low_t *in, uint8_t *out, int stride) {
|
|
||||||
vpx_highbd_idct32x32_1024_add_c(in, out, stride, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
void idct32x32_10(const tran_low_t *in, uint8_t *out, int stride) {
|
void idct32x32_10(const tran_low_t *in, uint8_t *out, int stride) {
|
||||||
vpx_highbd_idct32x32_1024_add_c(in, out, stride, 10);
|
vpx_highbd_idct32x32_1024_add_c(in, out, stride, 10);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const int kVideoNameParam = 1;
|
const int kVideoNameParam = 1;
|
||||||
const char kVP9TestFile[] = "vp90-2-02-size-lf-1920x1080.webm";
|
|
||||||
|
|
||||||
struct ExternalFrameBuffer {
|
struct ExternalFrameBuffer {
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
|
@ -155,6 +154,8 @@ class ExternalFrameBufferList {
|
||||||
ExternalFrameBuffer *ext_fb_list_;
|
ExternalFrameBuffer *ext_fb_list_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if CONFIG_WEBM_IO
|
||||||
|
|
||||||
// Callback used by libvpx to request the application to return a frame
|
// Callback used by libvpx to request the application to return a frame
|
||||||
// buffer of at least |min_size| in bytes.
|
// buffer of at least |min_size| in bytes.
|
||||||
int get_vp9_frame_buffer(void *user_priv, size_t min_size,
|
int get_vp9_frame_buffer(void *user_priv, size_t min_size,
|
||||||
|
@ -197,6 +198,8 @@ int do_not_release_vp9_frame_buffer(void *user_priv,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // CONFIG_WEBM_IO
|
||||||
|
|
||||||
// Class for testing passing in external frame buffers to libvpx.
|
// Class for testing passing in external frame buffers to libvpx.
|
||||||
class ExternalFrameBufferMD5Test
|
class ExternalFrameBufferMD5Test
|
||||||
: public ::libvpx_test::DecoderTest,
|
: public ::libvpx_test::DecoderTest,
|
||||||
|
@ -278,6 +281,8 @@ class ExternalFrameBufferMD5Test
|
||||||
};
|
};
|
||||||
|
|
||||||
#if CONFIG_WEBM_IO
|
#if CONFIG_WEBM_IO
|
||||||
|
const char kVP9TestFile[] = "vp90-2-02-size-lf-1920x1080.webm";
|
||||||
|
|
||||||
// Class for testing passing in external frame buffers to libvpx.
|
// Class for testing passing in external frame buffers to libvpx.
|
||||||
class ExternalFrameBufferTest : public ::testing::Test {
|
class ExternalFrameBufferTest : public ::testing::Test {
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -107,6 +107,8 @@ void iht8x8_12(const tran_low_t *in, uint8_t *out, int stride, int tx_type) {
|
||||||
vp9_highbd_iht8x8_64_add_c(in, out, stride, tx_type, 12);
|
vp9_highbd_iht8x8_64_add_c(in, out, stride, tx_type, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_SSE2
|
||||||
|
|
||||||
void idct8x8_10_add_10_c(const tran_low_t *in, uint8_t *out, int stride) {
|
void idct8x8_10_add_10_c(const tran_low_t *in, uint8_t *out, int stride) {
|
||||||
vpx_highbd_idct8x8_10_add_c(in, out, stride, 10);
|
vpx_highbd_idct8x8_10_add_c(in, out, stride, 10);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +117,6 @@ void idct8x8_10_add_12_c(const tran_low_t *in, uint8_t *out, int stride) {
|
||||||
vpx_highbd_idct8x8_10_add_c(in, out, stride, 12);
|
vpx_highbd_idct8x8_10_add_c(in, out, stride, 12);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_SSE2
|
|
||||||
void idct8x8_10_add_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
|
void idct8x8_10_add_10_sse2(const tran_low_t *in, uint8_t *out, int stride) {
|
||||||
vpx_highbd_idct8x8_10_add_sse2(in, out, stride, 10);
|
vpx_highbd_idct8x8_10_add_sse2(in, out, stride, 10);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2151,6 +2151,8 @@ static int test_candidate_kf(TWO_PASS *twopass,
|
||||||
return is_viable_kf;
|
return is_viable_kf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FRAMES_TO_CHECK_DECAY 8
|
||||||
|
|
||||||
static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
||||||
int i, j;
|
int i, j;
|
||||||
RATE_CONTROL *const rc = &cpi->rc;
|
RATE_CONTROL *const rc = &cpi->rc;
|
||||||
|
@ -2169,7 +2171,7 @@ static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
||||||
double boost_score = 0.0;
|
double boost_score = 0.0;
|
||||||
double kf_mod_err = 0.0;
|
double kf_mod_err = 0.0;
|
||||||
double kf_group_err = 0.0;
|
double kf_group_err = 0.0;
|
||||||
double recent_loop_decay[8] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
|
double recent_loop_decay[FRAMES_TO_CHECK_DECAY];
|
||||||
|
|
||||||
vp10_zero(next_frame);
|
vp10_zero(next_frame);
|
||||||
|
|
||||||
|
@ -2196,6 +2198,10 @@ static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
||||||
|
|
||||||
kf_mod_err = calculate_modified_err(cpi, twopass, oxcf, this_frame);
|
kf_mod_err = calculate_modified_err(cpi, twopass, oxcf, this_frame);
|
||||||
|
|
||||||
|
// Initialize the decay rates for the recent frames to check
|
||||||
|
for (j = 0; j < FRAMES_TO_CHECK_DECAY; ++j)
|
||||||
|
recent_loop_decay[j] = 1.0;
|
||||||
|
|
||||||
// Find the next keyframe.
|
// Find the next keyframe.
|
||||||
i = 0;
|
i = 0;
|
||||||
while (twopass->stats_in < twopass->stats_in_end &&
|
while (twopass->stats_in < twopass->stats_in_end &&
|
||||||
|
@ -2222,9 +2228,9 @@ static void find_next_key_frame(VP10_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
||||||
// We want to know something about the recent past... rather than
|
// We want to know something about the recent past... rather than
|
||||||
// as used elsewhere where we are concerned with decay in prediction
|
// as used elsewhere where we are concerned with decay in prediction
|
||||||
// quality since the last GF or KF.
|
// quality since the last GF or KF.
|
||||||
recent_loop_decay[i % 8] = loop_decay_rate;
|
recent_loop_decay[i % FRAMES_TO_CHECK_DECAY] = loop_decay_rate;
|
||||||
decay_accumulator = 1.0;
|
decay_accumulator = 1.0;
|
||||||
for (j = 0; j < 8; ++j)
|
for (j = 0; j < FRAMES_TO_CHECK_DECAY; ++j)
|
||||||
decay_accumulator *= recent_loop_decay[j];
|
decay_accumulator *= recent_loop_decay[j];
|
||||||
|
|
||||||
// Special check for transition or high motion followed by a
|
// Special check for transition or high motion followed by a
|
||||||
|
|
|
@ -310,6 +310,15 @@ if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
|
||||||
}
|
}
|
||||||
# End vp9_high encoder functions
|
# End vp9_high encoder functions
|
||||||
|
|
||||||
|
#
|
||||||
|
# frame based scale
|
||||||
|
#
|
||||||
|
if (vpx_config("CONFIG_VP9_HIGHBITDEPTH") eq "yes") {
|
||||||
|
} else {
|
||||||
|
add_proto qw/void vp9_scale_and_extend_frame/, "const struct yv12_buffer_config *src, struct yv12_buffer_config *dst";
|
||||||
|
specialize qw/vp9_scale_and_extend_frame ssse3/;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
# end encoder functions
|
# end encoder functions
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -23,14 +23,6 @@
|
||||||
#define EOB_CONTEXT_NODE 0
|
#define EOB_CONTEXT_NODE 0
|
||||||
#define ZERO_CONTEXT_NODE 1
|
#define ZERO_CONTEXT_NODE 1
|
||||||
#define ONE_CONTEXT_NODE 2
|
#define ONE_CONTEXT_NODE 2
|
||||||
#define LOW_VAL_CONTEXT_NODE 0
|
|
||||||
#define TWO_CONTEXT_NODE 1
|
|
||||||
#define THREE_CONTEXT_NODE 2
|
|
||||||
#define HIGH_LOW_CONTEXT_NODE 3
|
|
||||||
#define CAT_ONE_CONTEXT_NODE 4
|
|
||||||
#define CAT_THREEFOUR_CONTEXT_NODE 5
|
|
||||||
#define CAT_THREE_CONTEXT_NODE 6
|
|
||||||
#define CAT_FIVE_CONTEXT_NODE 7
|
|
||||||
|
|
||||||
#define INCREMENT_COUNT(token) \
|
#define INCREMENT_COUNT(token) \
|
||||||
do { \
|
do { \
|
||||||
|
|
|
@ -21,12 +21,6 @@
|
||||||
#include "vp9/encoder/vp9_rd.h"
|
#include "vp9/encoder/vp9_rd.h"
|
||||||
#include "vp9/encoder/vp9_segmentation.h"
|
#include "vp9/encoder/vp9_segmentation.h"
|
||||||
|
|
||||||
#define ENERGY_MIN (-4)
|
|
||||||
#define ENERGY_MAX (1)
|
|
||||||
#define ENERGY_SPAN (ENERGY_MAX - ENERGY_MIN + 1)
|
|
||||||
#define ENERGY_IN_BOUNDS(energy)\
|
|
||||||
assert((energy) >= ENERGY_MIN && (energy) <= ENERGY_MAX)
|
|
||||||
|
|
||||||
static const double rate_ratio[MAX_SEGMENTS] =
|
static const double rate_ratio[MAX_SEGMENTS] =
|
||||||
{1.0, 0.75, 0.6, 0.5, 0.4, 0.3, 0.25};
|
{1.0, 0.75, 0.6, 0.5, 0.4, 0.3, 0.25};
|
||||||
|
|
||||||
|
|
|
@ -35,9 +35,6 @@ static const double aq_c_var_thresholds[AQ_C_STRENGTHS][AQ_C_SEGMENTS] =
|
||||||
{-3.5, -2.5, -1.5, 100.00, 100.0},
|
{-3.5, -2.5, -1.5, 100.00, 100.0},
|
||||||
{-3.0, -2.0, -1.0, 100.00, 100.0} };
|
{-3.0, -2.0, -1.0, 100.00, 100.0} };
|
||||||
|
|
||||||
#define DEFAULT_COMPLEXITY 64
|
|
||||||
|
|
||||||
|
|
||||||
static int get_aq_c_strength(int q_index, vpx_bit_depth_t bit_depth) {
|
static int get_aq_c_strength(int q_index, vpx_bit_depth_t bit_depth) {
|
||||||
// Approximate base quatizer (truncated to int)
|
// Approximate base quatizer (truncated to int)
|
||||||
const int base_quant = vp9_ac_quant(q_index, 0, bit_depth) / 4;
|
const int base_quant = vp9_ac_quant(q_index, 0, bit_depth) / 4;
|
||||||
|
@ -107,7 +104,6 @@ void vp9_setup_in_frame_q_adj(VP9_COMP *cpi) {
|
||||||
|
|
||||||
#define DEFAULT_LV_THRESH 10.0
|
#define DEFAULT_LV_THRESH 10.0
|
||||||
#define MIN_DEFAULT_LV_THRESH 8.0
|
#define MIN_DEFAULT_LV_THRESH 8.0
|
||||||
#define VAR_STRENGTH_STEP 0.25
|
|
||||||
// Select a segment for the current block.
|
// Select a segment for the current block.
|
||||||
// The choice of segment for a block depends on the ratio of the projected
|
// The choice of segment for a block depends on the ratio of the projected
|
||||||
// bits for the block vs a target average and its spatial complexity.
|
// bits for the block vs a target average and its spatial complexity.
|
||||||
|
|
|
@ -62,8 +62,6 @@
|
||||||
#define AM_SEGMENT_ID_INACTIVE 7
|
#define AM_SEGMENT_ID_INACTIVE 7
|
||||||
#define AM_SEGMENT_ID_ACTIVE 0
|
#define AM_SEGMENT_ID_ACTIVE 0
|
||||||
|
|
||||||
#define SHARP_FILTER_QTHRESH 0 /* Q threshold for 8-tap sharp filter */
|
|
||||||
|
|
||||||
#define ALTREF_HIGH_PRECISION_MV 1 // Whether to use high precision mv
|
#define ALTREF_HIGH_PRECISION_MV 1 // Whether to use high precision mv
|
||||||
// for altref computation.
|
// for altref computation.
|
||||||
#define HIGH_PRECISION_MV_QTHRESH 200 // Q threshold for high precision
|
#define HIGH_PRECISION_MV_QTHRESH 200 // Q threshold for high precision
|
||||||
|
@ -1967,11 +1965,14 @@ VP9_COMP *vp9_create_compressor(VP9EncoderConfig *oxcf,
|
||||||
|
|
||||||
return cpi;
|
return cpi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_INTERNAL_STATS
|
||||||
#define SNPRINT(H, T) \
|
#define SNPRINT(H, T) \
|
||||||
snprintf((H) + strlen(H), sizeof(H) - strlen(H), (T))
|
snprintf((H) + strlen(H), sizeof(H) - strlen(H), (T))
|
||||||
|
|
||||||
#define SNPRINT2(H, T, V) \
|
#define SNPRINT2(H, T, V) \
|
||||||
snprintf((H) + strlen(H), sizeof(H) - strlen(H), (T), (V))
|
snprintf((H) + strlen(H), sizeof(H) - strlen(H), (T), (V))
|
||||||
|
#endif // CONFIG_INTERNAL_STATS
|
||||||
|
|
||||||
void vp9_remove_compressor(VP9_COMP *cpi) {
|
void vp9_remove_compressor(VP9_COMP *cpi) {
|
||||||
VP9_COMMON *cm;
|
VP9_COMMON *cm;
|
||||||
|
@ -2613,10 +2614,6 @@ static void scale_and_extend_frame_nonnormative(const YV12_BUFFER_CONFIG *src,
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
#if CONFIG_VP9_HIGHBITDEPTH
|
||||||
static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src,
|
static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src,
|
||||||
YV12_BUFFER_CONFIG *dst, int bd) {
|
YV12_BUFFER_CONFIG *dst, int bd) {
|
||||||
#else
|
|
||||||
static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src,
|
|
||||||
YV12_BUFFER_CONFIG *dst) {
|
|
||||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
|
||||||
const int src_w = src->y_crop_width;
|
const int src_w = src->y_crop_width;
|
||||||
const int src_h = src->y_crop_height;
|
const int src_h = src->y_crop_height;
|
||||||
const int dst_w = dst->y_crop_width;
|
const int dst_w = dst->y_crop_width;
|
||||||
|
@ -2628,19 +2625,18 @@ static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src,
|
||||||
const InterpKernel *const kernel = vp9_filter_kernels[EIGHTTAP];
|
const InterpKernel *const kernel = vp9_filter_kernels[EIGHTTAP];
|
||||||
int x, y, i;
|
int x, y, i;
|
||||||
|
|
||||||
for (y = 0; y < dst_h; y += 16) {
|
for (i = 0; i < MAX_MB_PLANE; ++i) {
|
||||||
for (x = 0; x < dst_w; x += 16) {
|
const int factor = (i == 0 || i == 3 ? 1 : 2);
|
||||||
for (i = 0; i < MAX_MB_PLANE; ++i) {
|
const int src_stride = src_strides[i];
|
||||||
const int factor = (i == 0 || i == 3 ? 1 : 2);
|
const int dst_stride = dst_strides[i];
|
||||||
|
for (y = 0; y < dst_h; y += 16) {
|
||||||
|
const int y_q4 = y * (16 / factor) * src_h / dst_h;
|
||||||
|
for (x = 0; x < dst_w; x += 16) {
|
||||||
const int x_q4 = x * (16 / factor) * src_w / dst_w;
|
const int x_q4 = x * (16 / factor) * src_w / dst_w;
|
||||||
const int y_q4 = y * (16 / factor) * src_h / dst_h;
|
|
||||||
const int src_stride = src_strides[i];
|
|
||||||
const int dst_stride = dst_strides[i];
|
|
||||||
const uint8_t *src_ptr = srcs[i] + (y / factor) * src_h / dst_h *
|
const uint8_t *src_ptr = srcs[i] + (y / factor) * src_h / dst_h *
|
||||||
src_stride + (x / factor) * src_w / dst_w;
|
src_stride + (x / factor) * src_w / dst_w;
|
||||||
uint8_t *dst_ptr = dsts[i] + (y / factor) * dst_stride + (x / factor);
|
uint8_t *dst_ptr = dsts[i] + (y / factor) * dst_stride + (x / factor);
|
||||||
|
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
|
||||||
if (src->flags & YV12_FLAG_HIGHBITDEPTH) {
|
if (src->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||||
vpx_highbd_convolve8(src_ptr, src_stride, dst_ptr, dst_stride,
|
vpx_highbd_convolve8(src_ptr, src_stride, dst_ptr, dst_stride,
|
||||||
kernel[x_q4 & 0xf], 16 * src_w / dst_w,
|
kernel[x_q4 & 0xf], 16 * src_w / dst_w,
|
||||||
|
@ -2652,18 +2648,49 @@ static void scale_and_extend_frame(const YV12_BUFFER_CONFIG *src,
|
||||||
kernel[y_q4 & 0xf], 16 * src_h / dst_h,
|
kernel[y_q4 & 0xf], 16 * src_h / dst_h,
|
||||||
16 / factor, 16 / factor);
|
16 / factor, 16 / factor);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
vpx_scaled_2d(src_ptr, src_stride, dst_ptr, dst_stride,
|
|
||||||
kernel[x_q4 & 0xf], 16 * src_w / dst_w,
|
|
||||||
kernel[y_q4 & 0xf], 16 * src_h / dst_h,
|
|
||||||
16 / factor, 16 / factor);
|
|
||||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vpx_extend_frame_borders(dst);
|
vpx_extend_frame_borders(dst);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void vp9_scale_and_extend_frame_c(const YV12_BUFFER_CONFIG *src,
|
||||||
|
YV12_BUFFER_CONFIG *dst) {
|
||||||
|
const int src_w = src->y_crop_width;
|
||||||
|
const int src_h = src->y_crop_height;
|
||||||
|
const int dst_w = dst->y_crop_width;
|
||||||
|
const int dst_h = dst->y_crop_height;
|
||||||
|
const uint8_t *const srcs[3] = {src->y_buffer, src->u_buffer, src->v_buffer};
|
||||||
|
const int src_strides[3] = {src->y_stride, src->uv_stride, src->uv_stride};
|
||||||
|
uint8_t *const dsts[3] = {dst->y_buffer, dst->u_buffer, dst->v_buffer};
|
||||||
|
const int dst_strides[3] = {dst->y_stride, dst->uv_stride, dst->uv_stride};
|
||||||
|
const InterpKernel *const kernel = vp9_filter_kernels[EIGHTTAP];
|
||||||
|
int x, y, i;
|
||||||
|
|
||||||
|
for (i = 0; i < MAX_MB_PLANE; ++i) {
|
||||||
|
const int factor = (i == 0 || i == 3 ? 1 : 2);
|
||||||
|
const int src_stride = src_strides[i];
|
||||||
|
const int dst_stride = dst_strides[i];
|
||||||
|
for (y = 0; y < dst_h; y += 16) {
|
||||||
|
const int y_q4 = y * (16 / factor) * src_h / dst_h;
|
||||||
|
for (x = 0; x < dst_w; x += 16) {
|
||||||
|
const int x_q4 = x * (16 / factor) * src_w / dst_w;
|
||||||
|
const uint8_t *src_ptr = srcs[i] + (y / factor) * src_h / dst_h *
|
||||||
|
src_stride + (x / factor) * src_w / dst_w;
|
||||||
|
uint8_t *dst_ptr = dsts[i] + (y / factor) * dst_stride + (x / factor);
|
||||||
|
|
||||||
|
vpx_scaled_2d(src_ptr, src_stride, dst_ptr, dst_stride,
|
||||||
|
kernel[x_q4 & 0xf], 16 * src_w / dst_w,
|
||||||
|
kernel[y_q4 & 0xf], 16 * src_h / dst_h,
|
||||||
|
16 / factor, 16 / factor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vpx_extend_frame_borders(dst);
|
||||||
|
}
|
||||||
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|
||||||
|
|
||||||
static int scale_down(VP9_COMP *cpi, int q) {
|
static int scale_down(VP9_COMP *cpi, int q) {
|
||||||
RATE_CONTROL *const rc = &cpi->rc;
|
RATE_CONTROL *const rc = &cpi->rc;
|
||||||
|
@ -2938,7 +2965,7 @@ void vp9_scale_references(VP9_COMP *cpi) {
|
||||||
cm->subsampling_x, cm->subsampling_y,
|
cm->subsampling_x, cm->subsampling_y,
|
||||||
VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
|
VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
scale_and_extend_frame(ref, &new_fb_ptr->buf);
|
vp9_scale_and_extend_frame(ref, &new_fb_ptr->buf);
|
||||||
cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
|
cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
|
||||||
alloc_frame_mvs(cm, new_fb);
|
alloc_frame_mvs(cm, new_fb);
|
||||||
}
|
}
|
||||||
|
@ -3302,7 +3329,6 @@ static void encode_without_recode_loop(VP9_COMP *cpi,
|
||||||
vpx_clear_system_state();
|
vpx_clear_system_state();
|
||||||
|
|
||||||
set_frame_size(cpi);
|
set_frame_size(cpi);
|
||||||
|
|
||||||
cpi->Source = vp9_scale_if_required(cm,
|
cpi->Source = vp9_scale_if_required(cm,
|
||||||
cpi->un_scaled_source,
|
cpi->un_scaled_source,
|
||||||
&cpi->scaled_source,
|
&cpi->scaled_source,
|
||||||
|
@ -3320,7 +3346,6 @@ static void encode_without_recode_loop(VP9_COMP *cpi,
|
||||||
cpi->unscaled_last_source,
|
cpi->unscaled_last_source,
|
||||||
&cpi->scaled_last_source,
|
&cpi->scaled_last_source,
|
||||||
(cpi->oxcf.pass == 0));
|
(cpi->oxcf.pass == 0));
|
||||||
|
|
||||||
vp9_update_noise_estimate(cpi);
|
vp9_update_noise_estimate(cpi);
|
||||||
|
|
||||||
if (cpi->oxcf.pass == 0 &&
|
if (cpi->oxcf.pass == 0 &&
|
||||||
|
@ -3742,7 +3767,7 @@ YV12_BUFFER_CONFIG *vp9_scale_if_required(VP9_COMMON *cm,
|
||||||
if (use_normative_scaler &&
|
if (use_normative_scaler &&
|
||||||
unscaled->y_width <= (scaled->y_width << 1) &&
|
unscaled->y_width <= (scaled->y_width << 1) &&
|
||||||
unscaled->y_height <= (scaled->y_height << 1))
|
unscaled->y_height <= (scaled->y_height << 1))
|
||||||
scale_and_extend_frame(unscaled, scaled);
|
vp9_scale_and_extend_frame(unscaled, scaled);
|
||||||
else
|
else
|
||||||
scale_and_extend_frame_nonnormative(unscaled, scaled);
|
scale_and_extend_frame_nonnormative(unscaled, scaled);
|
||||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|
||||||
|
|
|
@ -2260,6 +2260,8 @@ static int test_candidate_kf(TWO_PASS *twopass,
|
||||||
return is_viable_kf;
|
return is_viable_kf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define FRAMES_TO_CHECK_DECAY 8
|
||||||
|
|
||||||
static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
||||||
int i, j;
|
int i, j;
|
||||||
RATE_CONTROL *const rc = &cpi->rc;
|
RATE_CONTROL *const rc = &cpi->rc;
|
||||||
|
@ -2278,7 +2280,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
||||||
double boost_score = 0.0;
|
double boost_score = 0.0;
|
||||||
double kf_mod_err = 0.0;
|
double kf_mod_err = 0.0;
|
||||||
double kf_group_err = 0.0;
|
double kf_group_err = 0.0;
|
||||||
double recent_loop_decay[8] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
|
double recent_loop_decay[FRAMES_TO_CHECK_DECAY];
|
||||||
|
|
||||||
vp9_zero(next_frame);
|
vp9_zero(next_frame);
|
||||||
|
|
||||||
|
@ -2305,6 +2307,10 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
||||||
|
|
||||||
kf_mod_err = calculate_modified_err(cpi, twopass, oxcf, this_frame);
|
kf_mod_err = calculate_modified_err(cpi, twopass, oxcf, this_frame);
|
||||||
|
|
||||||
|
// Initialize the decay rates for the recent frames to check
|
||||||
|
for (j = 0; j < FRAMES_TO_CHECK_DECAY; ++j)
|
||||||
|
recent_loop_decay[j] = 1.0;
|
||||||
|
|
||||||
// Find the next keyframe.
|
// Find the next keyframe.
|
||||||
i = 0;
|
i = 0;
|
||||||
while (twopass->stats_in < twopass->stats_in_end &&
|
while (twopass->stats_in < twopass->stats_in_end &&
|
||||||
|
@ -2331,9 +2337,9 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
|
||||||
// We want to know something about the recent past... rather than
|
// We want to know something about the recent past... rather than
|
||||||
// as used elsewhere where we are concerned with decay in prediction
|
// as used elsewhere where we are concerned with decay in prediction
|
||||||
// quality since the last GF or KF.
|
// quality since the last GF or KF.
|
||||||
recent_loop_decay[i % 8] = loop_decay_rate;
|
recent_loop_decay[i % FRAMES_TO_CHECK_DECAY] = loop_decay_rate;
|
||||||
decay_accumulator = 1.0;
|
decay_accumulator = 1.0;
|
||||||
for (j = 0; j < 8; ++j)
|
for (j = 0; j < FRAMES_TO_CHECK_DECAY; ++j)
|
||||||
decay_accumulator *= recent_loop_decay[j];
|
decay_accumulator *= recent_loop_decay[j];
|
||||||
|
|
||||||
// Special check for transition or high motion followed by a
|
// Special check for transition or high motion followed by a
|
||||||
|
|
|
@ -153,10 +153,10 @@ void vp9_init3smotion_compensation(search_site_config *cfg, int stride) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* estimated cost of a motion vector (r,c) */
|
/* estimated cost of a motion vector (r,c) */
|
||||||
#define MVC(r, c) \
|
#define MVC(r, c) \
|
||||||
(mvcost ? \
|
(mvcost ? \
|
||||||
((mvjcost[((r) != rr) * 2 + ((c) != rc)] + \
|
((unsigned)(mvjcost[((r) != rr) * 2 + ((c) != rc)] + \
|
||||||
mvcost[0][((r) - rr)] + mvcost[1][((c) - rc)]) * \
|
mvcost[0][((r) - rr)] + mvcost[1][((c) - rc)]) * \
|
||||||
error_per_bit + 4096) >> 13 : 0)
|
error_per_bit + 4096) >> 13 : 0)
|
||||||
|
|
||||||
|
|
||||||
|
@ -849,9 +849,9 @@ static INLINE void calc_int_cost_list(const MACROBLOCK *x,
|
||||||
cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride,
|
cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride,
|
||||||
get_buf_from_mv(in_what, &this_mv),
|
get_buf_from_mv(in_what, &this_mv),
|
||||||
in_what->stride, &sse) +
|
in_what->stride, &sse) +
|
||||||
// mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb);
|
mv_err_cost(&this_mv, &fcenter_mv,
|
||||||
mv_err_cost(&this_mv, &fcenter_mv, x->nmvjointcost, x->mvcost,
|
x->nmvjointcost, x->mvcost,
|
||||||
x->errorperbit);
|
x->errorperbit);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
|
@ -863,9 +863,9 @@ static INLINE void calc_int_cost_list(const MACROBLOCK *x,
|
||||||
cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride,
|
cost_list[i + 1] = fn_ptr->vf(what->buf, what->stride,
|
||||||
get_buf_from_mv(in_what, &this_mv),
|
get_buf_from_mv(in_what, &this_mv),
|
||||||
in_what->stride, &sse) +
|
in_what->stride, &sse) +
|
||||||
// mvsad_err_cost(x, &this_mv, &fcenter_mv, sadpb);
|
mv_err_cost(&this_mv, &fcenter_mv,
|
||||||
mv_err_cost(&this_mv, &fcenter_mv, x->nmvjointcost, x->mvcost,
|
x->nmvjointcost, x->mvcost,
|
||||||
x->errorperbit);
|
x->errorperbit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3355,15 +3355,19 @@ void vp9_rd_pick_inter_mode_sb(VP9_COMP *cpi,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!disable_skip) {
|
if (!disable_skip) {
|
||||||
|
vpx_prob skip_prob = vp9_get_skip_prob(cm, xd);
|
||||||
if (skippable) {
|
if (skippable) {
|
||||||
// Back out the coefficient coding costs
|
// Back out the coefficient coding costs
|
||||||
rate2 -= (rate_y + rate_uv);
|
rate2 -= (rate_y + rate_uv);
|
||||||
|
|
||||||
// Cost the skip mb case
|
// Cost the skip mb case
|
||||||
rate2 += vp9_cost_bit(vp9_get_skip_prob(cm, xd), 1);
|
rate2 += vp9_cost_bit(skip_prob, 1);
|
||||||
} else if (ref_frame != INTRA_FRAME && !xd->lossless) {
|
} else if (ref_frame != INTRA_FRAME && !xd->lossless) {
|
||||||
if (RDCOST(x->rdmult, x->rddiv, rate_y + rate_uv, distortion2) <
|
if (RDCOST(x->rdmult, x->rddiv,
|
||||||
RDCOST(x->rdmult, x->rddiv, 0, total_sse)) {
|
rate_y + rate_uv + vp9_cost_bit(skip_prob, 0),
|
||||||
|
distortion2) <
|
||||||
|
RDCOST(x->rdmult, x->rddiv,
|
||||||
|
vp9_cost_bit(skip_prob, 1), total_sse)) {
|
||||||
// Add in the cost of the no skip flag.
|
// Add in the cost of the no skip flag.
|
||||||
rate2 += vp9_cost_bit(vp9_get_skip_prob(cm, xd), 0);
|
rate2 += vp9_cost_bit(vp9_get_skip_prob(cm, xd), 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "./vpx_config.h"
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
#if CONFIG_VP9_HIGHBITDEPTH
|
||||||
#include "vpx_dsp/vpx_dsp_common.h"
|
#include "vpx_dsp/vpx_dsp_common.h"
|
||||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|
||||||
|
|
|
@ -21,10 +21,11 @@
|
||||||
static const int skin_mean[5][2] = {
|
static const int skin_mean[5][2] = {
|
||||||
{7463, 9614}, {6400, 10240}, {7040, 10240}, {8320, 9280}, {6800, 9614}};
|
{7463, 9614}, {6400, 10240}, {7040, 10240}, {8320, 9280}, {6800, 9614}};
|
||||||
static const int skin_inv_cov[4] = {4107, 1663, 1663, 2157}; // q16
|
static const int skin_inv_cov[4] = {4107, 1663, 1663, 2157}; // q16
|
||||||
static const int skin_threshold[2] = {1570636, 800000}; // q18
|
static const int skin_threshold[6] = {1570636, 1400000, 800000, 800000, 800000,
|
||||||
|
800000}; // q18
|
||||||
|
|
||||||
// Thresholds on luminance.
|
// Thresholds on luminance.
|
||||||
static const int y_low = 20;
|
static const int y_low = 40;
|
||||||
static const int y_high = 220;
|
static const int y_high = 220;
|
||||||
|
|
||||||
// Evaluates the Mahalanobis distance measure for the input CbCr values.
|
// Evaluates the Mahalanobis distance measure for the input CbCr values.
|
||||||
|
@ -55,10 +56,24 @@ int vp9_skin_pixel(const uint8_t y, const uint8_t cb, const uint8_t cr) {
|
||||||
return (evaluate_skin_color_difference(cb, cr, 0) < skin_threshold[0]);
|
return (evaluate_skin_color_difference(cb, cr, 0) < skin_threshold[0]);
|
||||||
} else {
|
} else {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
// Exit on grey.
|
||||||
|
if (cb == 128 && cr == 128)
|
||||||
|
return 0;
|
||||||
|
// Exit on very strong cb.
|
||||||
|
if (cb > 150 && cr < 110)
|
||||||
|
return 0;
|
||||||
|
// Exit on (another) low luminance threshold if either color is high.
|
||||||
|
if (y < 50 && (cb > 140 || cr > 140))
|
||||||
|
return 0;
|
||||||
for (; i < 5; i++) {
|
for (; i < 5; i++) {
|
||||||
if (evaluate_skin_color_difference(cb, cr, i) < skin_threshold[1]) {
|
if (evaluate_skin_color_difference(cb, cr, i) < skin_threshold[i + 1]) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
// Exit if difference is much large than the threshold.
|
||||||
|
if (evaluate_skin_color_difference(cb, cr, i) >
|
||||||
|
(skin_threshold[i + 1] << 3)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "vp9/encoder/vp9_extend.h"
|
#include "vp9/encoder/vp9_extend.h"
|
||||||
#include "vpx_dsp/vpx_dsp_common.h"
|
#include "vpx_dsp/vpx_dsp_common.h"
|
||||||
|
|
||||||
#define SMALL_FRAME_FB_IDX 7
|
|
||||||
#define SMALL_FRAME_WIDTH 32
|
#define SMALL_FRAME_WIDTH 32
|
||||||
#define SMALL_FRAME_HEIGHT 16
|
#define SMALL_FRAME_HEIGHT 16
|
||||||
|
|
||||||
|
@ -644,6 +643,8 @@ int vp9_one_pass_cbr_svc_start_layer(VP9_COMP *const cpi) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_SPATIAL_SVC
|
#if CONFIG_SPATIAL_SVC
|
||||||
|
#define SMALL_FRAME_FB_IDX 7
|
||||||
|
|
||||||
int vp9_svc_start_frame(VP9_COMP *const cpi) {
|
int vp9_svc_start_frame(VP9_COMP *const cpi) {
|
||||||
int width = 0, height = 0;
|
int width = 0, height = 0;
|
||||||
LAYER_CONTEXT *lc;
|
LAYER_CONTEXT *lc;
|
||||||
|
@ -754,7 +755,8 @@ int vp9_svc_start_frame(VP9_COMP *const cpi) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#undef SMALL_FRAME_FB_IDX
|
||||||
|
#endif // CONFIG_SPATIAL_SVC
|
||||||
|
|
||||||
struct lookahead_entry *vp9_svc_lookahead_pop(VP9_COMP *const cpi,
|
struct lookahead_entry *vp9_svc_lookahead_pop(VP9_COMP *const cpi,
|
||||||
struct lookahead_ctx *ctx,
|
struct lookahead_ctx *ctx,
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
#include "vpx_ports/mem.h"
|
#include "vpx_ports/mem.h"
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
# define __likely__(v) __builtin_expect(v, 1)
|
# define LIKELY(v) __builtin_expect(v, 1)
|
||||||
# define __unlikely__(v) __builtin_expect(v, 0)
|
# define UNLIKELY(v) __builtin_expect(v, 0)
|
||||||
#else
|
#else
|
||||||
# define __likely__(v) (v)
|
# define LIKELY(v) (v)
|
||||||
# define __unlikely__(v) (v)
|
# define UNLIKELY(v) (v)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static INLINE int_mv pack_int_mv(int16_t row, int16_t col) {
|
static INLINE int_mv pack_int_mv(int16_t row, int16_t col) {
|
||||||
|
@ -50,8 +50,9 @@ static int mvsad_err_cost(const MACROBLOCK *x, const int_mv mv, const MV *ref,
|
||||||
int error_per_bit) {
|
int error_per_bit) {
|
||||||
const int_mv diff = pack_int_mv(mv.as_mv.row - ref->row,
|
const int_mv diff = pack_int_mv(mv.as_mv.row - ref->row,
|
||||||
mv.as_mv.col - ref->col);
|
mv.as_mv.col - ref->col);
|
||||||
return ROUND_POWER_OF_TWO(mv_cost(diff, x->nmvjointsadcost,
|
return ROUND_POWER_OF_TWO((unsigned)mv_cost(diff, x->nmvjointsadcost,
|
||||||
x->nmvsadcost) * error_per_bit, 8);
|
x->nmvsadcost) *
|
||||||
|
error_per_bit, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
@ -162,7 +163,7 @@ int vp9_diamond_search_sad_avx(const MACROBLOCK *x,
|
||||||
v_inside_d = _mm_cmpeq_epi32(v_these_mv_clamp_w, v_these_mv_w);
|
v_inside_d = _mm_cmpeq_epi32(v_these_mv_clamp_w, v_these_mv_w);
|
||||||
|
|
||||||
// If none of them are inside, then move on
|
// If none of them are inside, then move on
|
||||||
if (__likely__(_mm_test_all_zeros(v_inside_d, v_inside_d))) {
|
if (LIKELY(_mm_test_all_zeros(v_inside_d, v_inside_d))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +269,7 @@ int vp9_diamond_search_sad_avx(const MACROBLOCK *x,
|
||||||
// If the local best value is not saturated, just use it, otherwise
|
// If the local best value is not saturated, just use it, otherwise
|
||||||
// find the horizontal minimum again the hard way on 32 bits.
|
// find the horizontal minimum again the hard way on 32 bits.
|
||||||
// This is executed rarely.
|
// This is executed rarely.
|
||||||
if (__unlikely__(local_best_sad == 0xffff)) {
|
if (UNLIKELY(local_best_sad == 0xffff)) {
|
||||||
__m128i v_loval_d, v_hival_d, v_loidx_d, v_hiidx_d, v_sel_d;
|
__m128i v_loval_d, v_hival_d, v_loidx_d, v_hiidx_d, v_sel_d;
|
||||||
|
|
||||||
v_loval_d = v_sad_d;
|
v_loval_d = v_sad_d;
|
||||||
|
@ -293,7 +294,7 @@ int vp9_diamond_search_sad_avx(const MACROBLOCK *x,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the global minimum if the local minimum is smaller
|
// Update the global minimum if the local minimum is smaller
|
||||||
if (__likely__(local_best_sad < best_sad)) {
|
if (LIKELY(local_best_sad < best_sad)) {
|
||||||
new_bmv = ((const int_mv *)&v_these_mv_w)[local_best_idx];
|
new_bmv = ((const int_mv *)&v_these_mv_w)[local_best_idx];
|
||||||
new_best_address = ((const uint8_t **)v_blocka)[local_best_idx];
|
new_best_address = ((const uint8_t **)v_blocka)[local_best_idx];
|
||||||
|
|
||||||
|
@ -312,7 +313,7 @@ int vp9_diamond_search_sad_avx(const MACROBLOCK *x,
|
||||||
v_ba_d = _mm_set1_epi32((intptr_t)best_address);
|
v_ba_d = _mm_set1_epi32((intptr_t)best_address);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (__unlikely__(best_address == in_what)) {
|
if (UNLIKELY(best_address == in_what)) {
|
||||||
(*num00)++;
|
(*num00)++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,211 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && _MSC_VER <= 1500
|
||||||
|
// Need to include math.h before calling tmmintrin.h/intrin.h
|
||||||
|
// in certain versions of MSVS.
|
||||||
|
#include <math.h>
|
||||||
|
#endif
|
||||||
|
#include <tmmintrin.h> // SSSE3
|
||||||
|
|
||||||
|
#include "./vp9_rtcd.h"
|
||||||
|
#include "./vpx_dsp_rtcd.h"
|
||||||
|
#include "./vpx_scale_rtcd.h"
|
||||||
|
#include "vpx_scale/yv12config.h"
|
||||||
|
|
||||||
|
extern void vp9_scale_and_extend_frame_c(const YV12_BUFFER_CONFIG *src,
|
||||||
|
YV12_BUFFER_CONFIG *dst);
|
||||||
|
|
||||||
|
void downsample_2_to_1_ssse3(const uint8_t *src, ptrdiff_t src_stride,
|
||||||
|
uint8_t *dst, ptrdiff_t dst_stride,
|
||||||
|
int w, int h) {
|
||||||
|
const __m128i mask = _mm_set1_epi16(0x00FF);
|
||||||
|
const int max_width = w & ~15;
|
||||||
|
int y;
|
||||||
|
for (y = 0; y < h; ++y) {
|
||||||
|
int x;
|
||||||
|
for (x = 0; x < max_width; x += 16) {
|
||||||
|
const __m128i a = _mm_loadu_si128((const __m128i *)(src + x * 2 + 0));
|
||||||
|
const __m128i b = _mm_loadu_si128((const __m128i *)(src + x * 2 + 16));
|
||||||
|
const __m128i a_and = _mm_and_si128(a, mask);
|
||||||
|
const __m128i b_and = _mm_and_si128(b, mask);
|
||||||
|
const __m128i c = _mm_packus_epi16(a_and, b_and);
|
||||||
|
_mm_storeu_si128((__m128i *)(dst + x), c);
|
||||||
|
}
|
||||||
|
for (; x < w; ++x)
|
||||||
|
dst[x] = src[x * 2];
|
||||||
|
src += src_stride * 2;
|
||||||
|
dst += dst_stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static INLINE __m128i filter(const __m128i *const a, const __m128i *const b,
|
||||||
|
const __m128i *const c, const __m128i *const d,
|
||||||
|
const __m128i *const e, const __m128i *const f,
|
||||||
|
const __m128i *const g, const __m128i *const h) {
|
||||||
|
const __m128i coeffs_ab =
|
||||||
|
_mm_set_epi8(6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1, 6, -1);
|
||||||
|
const __m128i coeffs_cd =
|
||||||
|
_mm_set_epi8(78, -19, 78, -19, 78, -19, 78, -19, 78, -19, 78, -19,
|
||||||
|
78, -19, 78, -19);
|
||||||
|
const __m128i const64_x16 = _mm_set1_epi16(64);
|
||||||
|
const __m128i ab = _mm_unpacklo_epi8(*a, *b);
|
||||||
|
const __m128i cd = _mm_unpacklo_epi8(*c, *d);
|
||||||
|
const __m128i fe = _mm_unpacklo_epi8(*f, *e);
|
||||||
|
const __m128i hg = _mm_unpacklo_epi8(*h, *g);
|
||||||
|
const __m128i ab_terms = _mm_maddubs_epi16(ab, coeffs_ab);
|
||||||
|
const __m128i cd_terms = _mm_maddubs_epi16(cd, coeffs_cd);
|
||||||
|
const __m128i fe_terms = _mm_maddubs_epi16(fe, coeffs_cd);
|
||||||
|
const __m128i hg_terms = _mm_maddubs_epi16(hg, coeffs_ab);
|
||||||
|
// can not overflow
|
||||||
|
const __m128i abcd_terms = _mm_add_epi16(ab_terms, cd_terms);
|
||||||
|
// can not overflow
|
||||||
|
const __m128i fehg_terms = _mm_add_epi16(fe_terms, hg_terms);
|
||||||
|
// can overflow, use saturating add
|
||||||
|
const __m128i terms = _mm_adds_epi16(abcd_terms, fehg_terms);
|
||||||
|
const __m128i round = _mm_adds_epi16(terms, const64_x16);
|
||||||
|
const __m128i shift = _mm_srai_epi16(round, 7);
|
||||||
|
return _mm_packus_epi16(shift, shift);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void eight_tap_row_ssse3(const uint8_t *src, uint8_t *dst, int w) {
|
||||||
|
const int max_width = w & ~7;
|
||||||
|
int x = 0;
|
||||||
|
for (; x < max_width; x += 8) {
|
||||||
|
const __m128i a = _mm_loadl_epi64((const __m128i *)(src + x + 0));
|
||||||
|
const __m128i b = _mm_loadl_epi64((const __m128i *)(src + x + 1));
|
||||||
|
const __m128i c = _mm_loadl_epi64((const __m128i *)(src + x + 2));
|
||||||
|
const __m128i d = _mm_loadl_epi64((const __m128i *)(src + x + 3));
|
||||||
|
const __m128i e = _mm_loadl_epi64((const __m128i *)(src + x + 4));
|
||||||
|
const __m128i f = _mm_loadl_epi64((const __m128i *)(src + x + 5));
|
||||||
|
const __m128i g = _mm_loadl_epi64((const __m128i *)(src + x + 6));
|
||||||
|
const __m128i h = _mm_loadl_epi64((const __m128i *)(src + x + 7));
|
||||||
|
const __m128i pack = filter(&a, &b, &c, &d, &e, &f, &g, &h);
|
||||||
|
_mm_storel_epi64((__m128i *)(dst + x), pack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void upsample_1_to_2_ssse3(const uint8_t *src, ptrdiff_t src_stride,
|
||||||
|
uint8_t *dst, ptrdiff_t dst_stride,
|
||||||
|
int dst_w, int dst_h) {
|
||||||
|
dst_w /= 2;
|
||||||
|
dst_h /= 2;
|
||||||
|
{
|
||||||
|
DECLARE_ALIGNED(16, uint8_t, tmp[1920 * 8]);
|
||||||
|
uint8_t *tmp0 = tmp + dst_w * 0;
|
||||||
|
uint8_t *tmp1 = tmp + dst_w * 1;
|
||||||
|
uint8_t *tmp2 = tmp + dst_w * 2;
|
||||||
|
uint8_t *tmp3 = tmp + dst_w * 3;
|
||||||
|
uint8_t *tmp4 = tmp + dst_w * 4;
|
||||||
|
uint8_t *tmp5 = tmp + dst_w * 5;
|
||||||
|
uint8_t *tmp6 = tmp + dst_w * 6;
|
||||||
|
uint8_t *tmp7 = tmp + dst_w * 7;
|
||||||
|
uint8_t *tmp8 = NULL;
|
||||||
|
const int max_width = dst_w & ~7;
|
||||||
|
int y;
|
||||||
|
eight_tap_row_ssse3(src - src_stride * 3 - 3, tmp0, dst_w);
|
||||||
|
eight_tap_row_ssse3(src - src_stride * 2 - 3, tmp1, dst_w);
|
||||||
|
eight_tap_row_ssse3(src - src_stride * 1 - 3, tmp2, dst_w);
|
||||||
|
eight_tap_row_ssse3(src + src_stride * 0 - 3, tmp3, dst_w);
|
||||||
|
eight_tap_row_ssse3(src + src_stride * 1 - 3, tmp4, dst_w);
|
||||||
|
eight_tap_row_ssse3(src + src_stride * 2 - 3, tmp5, dst_w);
|
||||||
|
eight_tap_row_ssse3(src + src_stride * 3 - 3, tmp6, dst_w);
|
||||||
|
for (y = 0; y < dst_h; y++) {
|
||||||
|
int x;
|
||||||
|
eight_tap_row_ssse3(src + src_stride * 4 - 3, tmp7, dst_w);
|
||||||
|
for (x = 0; x < max_width; x += 8) {
|
||||||
|
const __m128i A = _mm_loadl_epi64((const __m128i *)(src + x));
|
||||||
|
const __m128i B = _mm_loadl_epi64((const __m128i *)(tmp3 + x));
|
||||||
|
const __m128i AB = _mm_unpacklo_epi8(A, B);
|
||||||
|
__m128i C, D, CD;
|
||||||
|
_mm_storeu_si128((__m128i *)(dst + x * 2), AB);
|
||||||
|
{
|
||||||
|
const __m128i a =
|
||||||
|
_mm_loadl_epi64((const __m128i *)(src + x - src_stride * 3));
|
||||||
|
const __m128i b =
|
||||||
|
_mm_loadl_epi64((const __m128i *)(src + x - src_stride * 2));
|
||||||
|
const __m128i c =
|
||||||
|
_mm_loadl_epi64((const __m128i *)(src + x - src_stride * 1));
|
||||||
|
const __m128i d =
|
||||||
|
_mm_loadl_epi64((const __m128i *)(src + x + src_stride * 0));
|
||||||
|
const __m128i e =
|
||||||
|
_mm_loadl_epi64((const __m128i *)(src + x + src_stride * 1));
|
||||||
|
const __m128i f =
|
||||||
|
_mm_loadl_epi64((const __m128i *)(src + x + src_stride * 2));
|
||||||
|
const __m128i g =
|
||||||
|
_mm_loadl_epi64((const __m128i *)(src + x + src_stride * 3));
|
||||||
|
const __m128i h =
|
||||||
|
_mm_loadl_epi64((const __m128i *)(src + x + src_stride * 4));
|
||||||
|
C = filter(&a, &b, &c, &d, &e, &f, &g, &h);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
const __m128i a = _mm_loadl_epi64((const __m128i *)(tmp0 + x));
|
||||||
|
const __m128i b = _mm_loadl_epi64((const __m128i *)(tmp1 + x));
|
||||||
|
const __m128i c = _mm_loadl_epi64((const __m128i *)(tmp2 + x));
|
||||||
|
const __m128i d = _mm_loadl_epi64((const __m128i *)(tmp3 + x));
|
||||||
|
const __m128i e = _mm_loadl_epi64((const __m128i *)(tmp4 + x));
|
||||||
|
const __m128i f = _mm_loadl_epi64((const __m128i *)(tmp5 + x));
|
||||||
|
const __m128i g = _mm_loadl_epi64((const __m128i *)(tmp6 + x));
|
||||||
|
const __m128i h = _mm_loadl_epi64((const __m128i *)(tmp7 + x));
|
||||||
|
D = filter(&a, &b, &c, &d, &e, &f, &g, &h);
|
||||||
|
}
|
||||||
|
CD = _mm_unpacklo_epi8(C, D);
|
||||||
|
_mm_storeu_si128((__m128i *)(dst + x * 2 + dst_stride), CD);
|
||||||
|
}
|
||||||
|
src += src_stride;
|
||||||
|
dst += dst_stride * 2;
|
||||||
|
tmp8 = tmp0;
|
||||||
|
tmp0 = tmp1;
|
||||||
|
tmp1 = tmp2;
|
||||||
|
tmp2 = tmp3;
|
||||||
|
tmp3 = tmp4;
|
||||||
|
tmp4 = tmp5;
|
||||||
|
tmp5 = tmp6;
|
||||||
|
tmp6 = tmp7;
|
||||||
|
tmp7 = tmp8;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void vp9_scale_and_extend_frame_ssse3(const YV12_BUFFER_CONFIG *src,
|
||||||
|
YV12_BUFFER_CONFIG *dst) {
|
||||||
|
const int src_w = src->y_crop_width;
|
||||||
|
const int src_h = src->y_crop_height;
|
||||||
|
const int dst_w = dst->y_crop_width;
|
||||||
|
const int dst_h = dst->y_crop_height;
|
||||||
|
const int dst_uv_w = dst_w / 2;
|
||||||
|
const int dst_uv_h = dst_h / 2;
|
||||||
|
|
||||||
|
if (dst_w * 2 == src_w && dst_h * 2 == src_h) {
|
||||||
|
downsample_2_to_1_ssse3(src->y_buffer, src->y_stride,
|
||||||
|
dst->y_buffer, dst->y_stride, dst_w, dst_h);
|
||||||
|
downsample_2_to_1_ssse3(src->u_buffer, src->uv_stride,
|
||||||
|
dst->u_buffer, dst->uv_stride, dst_uv_w, dst_uv_h);
|
||||||
|
downsample_2_to_1_ssse3(src->v_buffer, src->uv_stride,
|
||||||
|
dst->v_buffer, dst->uv_stride, dst_uv_w, dst_uv_h);
|
||||||
|
vpx_extend_frame_borders(dst);
|
||||||
|
} else if (dst_w == src_w * 2 && dst_h == src_h * 2) {
|
||||||
|
// The upsample() supports widths up to 1920 * 2. If greater, fall back
|
||||||
|
// to vp9_scale_and_extend_frame_c().
|
||||||
|
if (dst_w/2 <= 1920) {
|
||||||
|
upsample_1_to_2_ssse3(src->y_buffer, src->y_stride,
|
||||||
|
dst->y_buffer, dst->y_stride, dst_w, dst_h);
|
||||||
|
upsample_1_to_2_ssse3(src->u_buffer, src->uv_stride,
|
||||||
|
dst->u_buffer, dst->uv_stride, dst_uv_w, dst_uv_h);
|
||||||
|
upsample_1_to_2_ssse3(src->v_buffer, src->uv_stride,
|
||||||
|
dst->v_buffer, dst->uv_stride, dst_uv_w, dst_uv_h);
|
||||||
|
vpx_extend_frame_borders(dst);
|
||||||
|
} else {
|
||||||
|
vp9_scale_and_extend_frame_c(src, dst);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
vp9_scale_and_extend_frame_c(src, dst);
|
||||||
|
}
|
||||||
|
}
|
|
@ -119,6 +119,7 @@ endif
|
||||||
|
|
||||||
VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_dct_sse2.c
|
VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_dct_sse2.c
|
||||||
VP9_CX_SRCS-$(HAVE_SSSE3) += encoder/x86/vp9_dct_ssse3.c
|
VP9_CX_SRCS-$(HAVE_SSSE3) += encoder/x86/vp9_dct_ssse3.c
|
||||||
|
VP9_CX_SRCS-$(HAVE_SSSE3) += encoder/x86/vp9_frame_scale_ssse3.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_VP9_TEMPORAL_DENOISING),yes)
|
ifeq ($(CONFIG_VP9_TEMPORAL_DENOISING),yes)
|
||||||
VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_denoiser_sse2.c
|
VP9_CX_SRCS-$(HAVE_SSE2) += encoder/x86/vp9_denoiser_sse2.c
|
||||||
|
|
|
@ -528,6 +528,7 @@ static INLINE void highbd_d207_predictor(uint16_t *dst, ptrdiff_t stride,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_MISC_FIXES
|
||||||
static INLINE void highbd_d207e_predictor(uint16_t *dst, ptrdiff_t stride,
|
static INLINE void highbd_d207e_predictor(uint16_t *dst, ptrdiff_t stride,
|
||||||
int bs, const uint16_t *above,
|
int bs, const uint16_t *above,
|
||||||
const uint16_t *left, int bd) {
|
const uint16_t *left, int bd) {
|
||||||
|
@ -544,6 +545,7 @@ static INLINE void highbd_d207e_predictor(uint16_t *dst, ptrdiff_t stride,
|
||||||
dst += stride;
|
dst += stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // CONFIG_MISC_FIXES
|
||||||
|
|
||||||
static INLINE void highbd_d63_predictor(uint16_t *dst, ptrdiff_t stride,
|
static INLINE void highbd_d63_predictor(uint16_t *dst, ptrdiff_t stride,
|
||||||
int bs, const uint16_t *above,
|
int bs, const uint16_t *above,
|
||||||
|
@ -579,6 +581,7 @@ static INLINE void highbd_d45_predictor(uint16_t *dst, ptrdiff_t stride, int bs,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if CONFIG_MISC_FIXES
|
||||||
static INLINE void highbd_d45e_predictor(uint16_t *dst, ptrdiff_t stride,
|
static INLINE void highbd_d45e_predictor(uint16_t *dst, ptrdiff_t stride,
|
||||||
int bs, const uint16_t *above,
|
int bs, const uint16_t *above,
|
||||||
const uint16_t *left, int bd) {
|
const uint16_t *left, int bd) {
|
||||||
|
@ -593,6 +596,7 @@ static INLINE void highbd_d45e_predictor(uint16_t *dst, ptrdiff_t stride,
|
||||||
dst += stride;
|
dst += stride;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif // CONFIG_MISC_FIXES
|
||||||
|
|
||||||
static INLINE void highbd_d117_predictor(uint16_t *dst, ptrdiff_t stride,
|
static INLINE void highbd_d117_predictor(uint16_t *dst, ptrdiff_t stride,
|
||||||
int bs, const uint16_t *above,
|
int bs, const uint16_t *above,
|
||||||
|
|
|
@ -9,8 +9,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define __VPX_MEM_C__
|
|
||||||
|
|
||||||
#include "vpx_mem.h"
|
#include "vpx_mem.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
|
@ -160,29 +160,12 @@ int vpx_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf,
|
||||||
const uint64_t uvplane_size = (uv_height + 2 * uv_border_h) *
|
const uint64_t uvplane_size = (uv_height + 2 * uv_border_h) *
|
||||||
(uint64_t)uv_stride + byte_alignment;
|
(uint64_t)uv_stride + byte_alignment;
|
||||||
|
|
||||||
#if CONFIG_ALPHA
|
|
||||||
const int alpha_width = aligned_width;
|
|
||||||
const int alpha_height = aligned_height;
|
|
||||||
const int alpha_stride = y_stride;
|
|
||||||
const int alpha_border_w = border;
|
|
||||||
const int alpha_border_h = border;
|
|
||||||
const uint64_t alpha_plane_size = (alpha_height + 2 * alpha_border_h) *
|
|
||||||
(uint64_t)alpha_stride + byte_alignment;
|
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
|
||||||
const uint64_t frame_size = (1 + use_highbitdepth) *
|
|
||||||
(yplane_size + 2 * uvplane_size + alpha_plane_size);
|
|
||||||
#else
|
|
||||||
const uint64_t frame_size = yplane_size + 2 * uvplane_size +
|
|
||||||
alpha_plane_size;
|
|
||||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
|
||||||
#else
|
|
||||||
#if CONFIG_VP9_HIGHBITDEPTH
|
#if CONFIG_VP9_HIGHBITDEPTH
|
||||||
const uint64_t frame_size =
|
const uint64_t frame_size =
|
||||||
(1 + use_highbitdepth) * (yplane_size + 2 * uvplane_size);
|
(1 + use_highbitdepth) * (yplane_size + 2 * uvplane_size);
|
||||||
#else
|
#else
|
||||||
const uint64_t frame_size = yplane_size + 2 * uvplane_size;
|
const uint64_t frame_size = yplane_size + 2 * uvplane_size;
|
||||||
#endif // CONFIG_VP9_HIGHBITDEPTH
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|
||||||
#endif // CONFIG_ALPHA
|
|
||||||
|
|
||||||
uint8_t *buf = NULL;
|
uint8_t *buf = NULL;
|
||||||
|
|
||||||
|
@ -277,14 +260,6 @@ int vpx_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf,
|
||||||
buf + yplane_size + uvplane_size + (uv_border_h * uv_stride) +
|
buf + yplane_size + uvplane_size + (uv_border_h * uv_stride) +
|
||||||
uv_border_w, vp9_byte_align);
|
uv_border_w, vp9_byte_align);
|
||||||
|
|
||||||
#if CONFIG_ALPHA
|
|
||||||
ybf->alpha_width = alpha_width;
|
|
||||||
ybf->alpha_height = alpha_height;
|
|
||||||
ybf->alpha_stride = alpha_stride;
|
|
||||||
ybf->alpha_buffer = (uint8_t *)yv12_align_addr(
|
|
||||||
buf + yplane_size + 2 * uvplane_size +
|
|
||||||
(alpha_border_h * alpha_stride) + alpha_border_w, vp9_byte_align);
|
|
||||||
#endif
|
|
||||||
ybf->corrupted = 0; /* assume not corrupted by errors */
|
ybf->corrupted = 0; /* assume not corrupted by errors */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче