2010-05-18 19:58:33 +04:00
|
|
|
/*
|
2015-07-16 05:14:54 +03:00
|
|
|
* Copyright (c) 2015 The WebM project authors. All Rights Reserved.
|
2010-05-18 19:58:33 +04:00
|
|
|
*
|
2010-06-18 20:39:21 +04:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-05 00:19:40 +04:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 20:39:21 +04:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-05 00:19:40 +04:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 19:58:33 +04:00
|
|
|
*/
|
2012-11-01 03:09:17 +04:00
|
|
|
|
2015-07-22 20:40:42 +03:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
2013-09-30 06:03:00 +04:00
|
|
|
#include "./vpx_config.h"
|
2016-05-05 01:06:44 +03:00
|
|
|
#include "./vpx_dsp_rtcd.h"
|
2015-07-15 23:02:01 +03:00
|
|
|
#include "vpx_dsp/vpx_dsp_common.h"
|
2015-05-12 05:09:22 +03:00
|
|
|
#include "vpx_ports/mem.h"
|
2010-05-18 19:58:33 +04:00
|
|
|
|
2013-02-07 00:45:28 +04:00
|
|
|
static INLINE int8_t signed_char_clamp(int t) {
|
2013-05-14 05:09:11 +04:00
|
|
|
return (int8_t)clamp(t, -128, 127);
|
2010-05-18 19:58:33 +04:00
|
|
|
}
|
|
|
|
|
2014-09-18 03:55:05 +04:00
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
static INLINE int16_t signed_char_clamp_high(int t, int bd) {
|
|
|
|
switch (bd) {
|
2016-08-09 08:59:08 +03:00
|
|
|
case 10: return (int16_t)clamp(t, -128 * 4, 128 * 4 - 1);
|
|
|
|
case 12: return (int16_t)clamp(t, -128 * 16, 128 * 16 - 1);
|
2014-09-18 03:55:05 +04:00
|
|
|
case 8:
|
2016-08-09 08:59:08 +03:00
|
|
|
default: return (int16_t)clamp(t, -128, 128 - 1);
|
2014-09-18 03:55:05 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-04-02 05:23:04 +04:00
|
|
|
// should we apply any filter at all: 11111111 yes, 00000000 no
|
2016-08-09 08:59:08 +03:00
|
|
|
static INLINE int8_t filter_mask(uint8_t limit, uint8_t blimit, uint8_t p3,
|
|
|
|
uint8_t p2, uint8_t p1, uint8_t p0, uint8_t q0,
|
|
|
|
uint8_t q1, uint8_t q2, uint8_t q3) {
|
2012-12-19 03:31:19 +04:00
|
|
|
int8_t mask = 0;
|
2012-07-14 02:21:29 +04:00
|
|
|
mask |= (abs(p3 - p2) > limit) * -1;
|
|
|
|
mask |= (abs(p2 - p1) > limit) * -1;
|
|
|
|
mask |= (abs(p1 - p0) > limit) * -1;
|
|
|
|
mask |= (abs(q1 - q0) > limit) * -1;
|
|
|
|
mask |= (abs(q2 - q1) > limit) * -1;
|
|
|
|
mask |= (abs(q3 - q2) > limit) * -1;
|
2016-08-09 08:59:08 +03:00
|
|
|
mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit) * -1;
|
2013-04-02 05:23:04 +04:00
|
|
|
return ~mask;
|
2010-05-18 19:58:33 +04:00
|
|
|
}
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
static INLINE int8_t flat_mask4(uint8_t thresh, uint8_t p3, uint8_t p2,
|
|
|
|
uint8_t p1, uint8_t p0, uint8_t q0, uint8_t q1,
|
2013-07-16 03:01:31 +04:00
|
|
|
uint8_t q2, uint8_t q3) {
|
2013-07-17 01:39:31 +04:00
|
|
|
int8_t mask = 0;
|
|
|
|
mask |= (abs(p1 - p0) > thresh) * -1;
|
|
|
|
mask |= (abs(q1 - q0) > thresh) * -1;
|
|
|
|
mask |= (abs(p2 - p0) > thresh) * -1;
|
|
|
|
mask |= (abs(q2 - q0) > thresh) * -1;
|
|
|
|
mask |= (abs(p3 - p0) > thresh) * -1;
|
|
|
|
mask |= (abs(q3 - q0) > thresh) * -1;
|
|
|
|
return ~mask;
|
2013-07-16 03:01:31 +04:00
|
|
|
}
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
static INLINE int8_t flat_mask5(uint8_t thresh, uint8_t p4, uint8_t p3,
|
|
|
|
uint8_t p2, uint8_t p1, uint8_t p0, uint8_t q0,
|
|
|
|
uint8_t q1, uint8_t q2, uint8_t q3,
|
|
|
|
uint8_t q4) {
|
2013-07-17 01:39:31 +04:00
|
|
|
int8_t mask = ~flat_mask4(thresh, p3, p2, p1, p0, q0, q1, q2, q3);
|
|
|
|
mask |= (abs(p4 - p0) > thresh) * -1;
|
|
|
|
mask |= (abs(q4 - q0) > thresh) * -1;
|
|
|
|
return ~mask;
|
2013-07-16 03:01:31 +04:00
|
|
|
}
|
|
|
|
|
2013-05-14 05:09:11 +04:00
|
|
|
// is there high edge variance internal edge: 11111111 yes, 00000000 no
|
2013-07-16 03:01:31 +04:00
|
|
|
static INLINE int8_t hev_mask(uint8_t thresh, uint8_t p1, uint8_t p0,
|
|
|
|
uint8_t q0, uint8_t q1) {
|
2012-12-19 03:31:19 +04:00
|
|
|
int8_t hev = 0;
|
2016-08-09 08:59:08 +03:00
|
|
|
hev |= (abs(p1 - p0) > thresh) * -1;
|
|
|
|
hev |= (abs(q1 - q0) > thresh) * -1;
|
2012-07-14 02:21:29 +04:00
|
|
|
return hev;
|
2010-05-18 19:58:33 +04:00
|
|
|
}
|
|
|
|
|
2013-12-18 03:23:23 +04:00
|
|
|
static INLINE void filter4(int8_t mask, uint8_t thresh, uint8_t *op1,
|
2013-07-16 03:01:31 +04:00
|
|
|
uint8_t *op0, uint8_t *oq0, uint8_t *oq1) {
|
2013-03-26 22:08:34 +04:00
|
|
|
int8_t filter1, filter2;
|
2012-07-14 02:21:29 +04:00
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t ps1 = (int8_t)*op1 ^ 0x80;
|
|
|
|
const int8_t ps0 = (int8_t)*op0 ^ 0x80;
|
|
|
|
const int8_t qs0 = (int8_t)*oq0 ^ 0x80;
|
|
|
|
const int8_t qs1 = (int8_t)*oq1 ^ 0x80;
|
2013-12-18 03:23:23 +04:00
|
|
|
const uint8_t hev = hev_mask(thresh, *op1, *op0, *oq0, *oq1);
|
2013-03-26 22:08:34 +04:00
|
|
|
|
|
|
|
// add outer taps if we have high edge variance
|
|
|
|
int8_t filter = signed_char_clamp(ps1 - qs1) & hev;
|
|
|
|
|
|
|
|
// inner taps
|
|
|
|
filter = signed_char_clamp(filter + 3 * (qs0 - ps0)) & mask;
|
|
|
|
|
|
|
|
// save bottom 3 bits so that we round one side +4 and the other +3
|
|
|
|
// if it equals 4 we'll set to adjust by -1 to account for the fact
|
|
|
|
// we'd round 3 the other way
|
|
|
|
filter1 = signed_char_clamp(filter + 4) >> 3;
|
|
|
|
filter2 = signed_char_clamp(filter + 3) >> 3;
|
|
|
|
|
|
|
|
*oq0 = signed_char_clamp(qs0 - filter1) ^ 0x80;
|
|
|
|
*op0 = signed_char_clamp(ps0 + filter2) ^ 0x80;
|
|
|
|
|
|
|
|
// outer tap adjustments
|
2013-07-17 01:39:31 +04:00
|
|
|
filter = ROUND_POWER_OF_TWO(filter1, 1) & ~hev;
|
2012-07-14 02:21:29 +04:00
|
|
|
|
2013-03-26 22:08:34 +04:00
|
|
|
*oq1 = signed_char_clamp(qs1 - filter) ^ 0x80;
|
|
|
|
*op1 = signed_char_clamp(ps1 + filter) ^ 0x80;
|
2012-07-14 02:21:29 +04:00
|
|
|
}
|
2012-10-19 01:29:26 +04:00
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_lpf_horizontal_4_c(uint8_t *s, int p /* pitch */,
|
2013-12-18 05:34:34 +04:00
|
|
|
const uint8_t *blimit, const uint8_t *limit,
|
2016-02-12 07:26:54 +03:00
|
|
|
const uint8_t *thresh) {
|
2013-05-14 05:09:11 +04:00
|
|
|
int i;
|
2012-07-14 02:21:29 +04:00
|
|
|
|
2013-04-02 05:23:04 +04:00
|
|
|
// loop filter designed to work using chars so that we can make maximum use
|
|
|
|
// of 8 bit simd instructions.
|
2016-02-12 07:26:54 +03:00
|
|
|
for (i = 0; i < 8; ++i) {
|
2013-05-14 05:09:11 +04:00
|
|
|
const uint8_t p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p];
|
2016-08-09 08:59:08 +03:00
|
|
|
const uint8_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p];
|
|
|
|
const int8_t mask =
|
|
|
|
filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3);
|
2013-12-18 03:23:23 +04:00
|
|
|
filter4(mask, *thresh, s - 2 * p, s - 1 * p, s, s + 1 * p);
|
2012-07-14 02:21:29 +04:00
|
|
|
++s;
|
2013-05-14 05:09:11 +04:00
|
|
|
}
|
2012-07-14 02:21:29 +04:00
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_lpf_horizontal_4_dual_c(uint8_t *s, int p, const uint8_t *blimit0,
|
2013-12-18 05:34:34 +04:00
|
|
|
const uint8_t *limit0, const uint8_t *thresh0,
|
|
|
|
const uint8_t *blimit1, const uint8_t *limit1,
|
|
|
|
const uint8_t *thresh1) {
|
2016-02-12 07:26:54 +03:00
|
|
|
vpx_lpf_horizontal_4_c(s, p, blimit0, limit0, thresh0);
|
|
|
|
vpx_lpf_horizontal_4_c(s + 8, p, blimit1, limit1, thresh1);
|
2013-11-13 04:51:15 +04:00
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_lpf_vertical_4_c(uint8_t *s, int pitch, const uint8_t *blimit,
|
2016-02-12 06:54:51 +03:00
|
|
|
const uint8_t *limit, const uint8_t *thresh) {
|
2013-05-14 05:09:11 +04:00
|
|
|
int i;
|
2012-07-14 02:21:29 +04:00
|
|
|
|
2013-04-02 05:23:04 +04:00
|
|
|
// loop filter designed to work using chars so that we can make maximum use
|
|
|
|
// of 8 bit simd instructions.
|
2016-02-12 06:54:51 +03:00
|
|
|
for (i = 0; i < 8; ++i) {
|
2013-05-14 05:09:11 +04:00
|
|
|
const uint8_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1];
|
2016-08-09 08:59:08 +03:00
|
|
|
const uint8_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3];
|
|
|
|
const int8_t mask =
|
|
|
|
filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3);
|
2013-12-18 03:23:23 +04:00
|
|
|
filter4(mask, *thresh, s - 2, s - 1, s, s + 1);
|
2013-04-02 05:23:04 +04:00
|
|
|
s += pitch;
|
2013-05-14 05:09:11 +04:00
|
|
|
}
|
2012-07-14 02:21:29 +04:00
|
|
|
}
|
2013-05-14 05:09:11 +04:00
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_lpf_vertical_4_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0,
|
2013-12-18 05:34:34 +04:00
|
|
|
const uint8_t *limit0, const uint8_t *thresh0,
|
|
|
|
const uint8_t *blimit1, const uint8_t *limit1,
|
|
|
|
const uint8_t *thresh1) {
|
2016-02-12 06:54:51 +03:00
|
|
|
vpx_lpf_vertical_4_c(s, pitch, blimit0, limit0, thresh0);
|
|
|
|
vpx_lpf_vertical_4_c(s + 8 * pitch, pitch, blimit1, limit1, thresh1);
|
2013-11-22 04:43:37 +04:00
|
|
|
}
|
|
|
|
|
2013-12-18 03:23:23 +04:00
|
|
|
static INLINE void filter8(int8_t mask, uint8_t thresh, uint8_t flat,
|
2016-08-09 08:59:08 +03:00
|
|
|
uint8_t *op3, uint8_t *op2, uint8_t *op1,
|
|
|
|
uint8_t *op0, uint8_t *oq0, uint8_t *oq1,
|
2013-07-16 03:01:31 +04:00
|
|
|
uint8_t *oq2, uint8_t *oq3) {
|
2012-07-14 02:21:29 +04:00
|
|
|
if (flat && mask) {
|
2013-05-14 05:09:11 +04:00
|
|
|
const uint8_t p3 = *op3, p2 = *op2, p1 = *op1, p0 = *op0;
|
|
|
|
const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3;
|
2012-07-14 02:21:29 +04:00
|
|
|
|
2013-07-17 01:39:31 +04:00
|
|
|
// 7-tap filter [1, 1, 1, 2, 1, 1, 1]
|
|
|
|
*op2 = ROUND_POWER_OF_TWO(p3 + p3 + p3 + 2 * p2 + p1 + p0 + q0, 3);
|
|
|
|
*op1 = ROUND_POWER_OF_TWO(p3 + p3 + p2 + 2 * p1 + p0 + q0 + q1, 3);
|
|
|
|
*op0 = ROUND_POWER_OF_TWO(p3 + p2 + p1 + 2 * p0 + q0 + q1 + q2, 3);
|
|
|
|
*oq0 = ROUND_POWER_OF_TWO(p2 + p1 + p0 + 2 * q0 + q1 + q2 + q3, 3);
|
|
|
|
*oq1 = ROUND_POWER_OF_TWO(p1 + p0 + q0 + 2 * q1 + q2 + q3 + q3, 3);
|
|
|
|
*oq2 = ROUND_POWER_OF_TWO(p0 + q0 + q1 + 2 * q2 + q3 + q3 + q3, 3);
|
2012-07-14 02:21:29 +04:00
|
|
|
} else {
|
2016-08-09 08:59:08 +03:00
|
|
|
filter4(mask, thresh, op1, op0, oq0, oq1);
|
2012-07-14 02:21:29 +04:00
|
|
|
}
|
WebM Experimental Codec Branch Snapshot
This is a code snapshot of experimental work currently ongoing for a
next-generation codec.
The codebase has been cut down considerably from the libvpx baseline.
For example, we are currently only supporting VBR 2-pass rate control
and have removed most of the code relating to coding speed, threading,
error resilience, partitions and various other features. This is in
part to make the codebase easier to work on and experiment with, but
also because we want to have an open discussion about how the bitstream
will be structured and partitioned and not have that conversation
constrained by past work.
Our basic working pattern has been to initially encapsulate experiments
using configure options linked to #IF CONFIG_XXX statements in the
code. Once experiments have matured and we are reasonably happy that
they give benefit and can be merged without breaking other experiments,
we remove the conditional compile statements and merge them in.
Current changes include:
* Temporal coding experiment for segments (though still only 4 max, it
will likely be increased).
* Segment feature experiment - to allow various bits of information to
be coded at the segment level. Features tested so far include mode
and reference frame information, limiting end of block offset and
transform size, alongside Q and loop filter parameters, but this set
is very fluid.
* Support for 8x8 transform - 8x8 dct with 2nd order 2x2 haar is used
in MBs using 16x16 prediction modes within inter frames.
* Compound prediction (combination of signals from existing predictors
to create a new predictor).
* 8 tap interpolation filters and 1/8th pel motion vectors.
* Loop filter modifications.
* Various entropy modifications and changes to how entropy contexts and
updates are handled.
* Extended quantizer range matched to transform precision improvements.
There are also ongoing further experiments that we hope to merge in the
near future: For example, coding of motion and other aspects of the
prediction signal to better support larger image formats, use of larger
block sizes (e.g. 32x32 and up) and lossless non-transform based coding
options (especially for key frames). It is our hope that we will be
able to make regular updates and we will warmly welcome community
contributions.
Please be warned that, at this stage, the codebase is currently slower
than VP8 stable branch as most new code has not been optimized, and
even the 'C' has been deliberately written to be simple and obvious,
not fast.
The following graphs have the initial test results, numbers in the
tables measure the compression improvement in terms of percentage. The
build has the following optional experiments configured:
--enable-experimental --enable-enhanced_interp --enable-uvintra
--enable-high_precision_mv --enable-sixteenth_subpel_uv
CIF Size clips:
http://getwebm.org/tmp/cif/
HD size clips:
http://getwebm.org/tmp/hd/
(stable_20120309 represents encoding results of WebM master branch
build as of commit#7a15907)
They were encoded using the following encode parameters:
--good --cpu-used=0 -t 0 --lag-in-frames=25 --min-q=0 --max-q=63
--end-usage=0 --auto-alt-ref=1 -p 2 --pass=2 --kf-max-dist=9999
--kf-min-dist=0 --drop-frame=0 --static-thresh=0 --bias-pct=50
--minsection-pct=0 --maxsection-pct=800 --sharpness=0
--arnr-maxframes=7 --arnr-strength=3(for HD,6 for CIF)
--arnr-type=3
Change-Id: I5c62ed09cfff5815a2bb34e7820d6a810c23183c
2012-03-10 05:32:50 +04:00
|
|
|
}
|
2012-12-19 03:31:19 +04:00
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_lpf_horizontal_8_c(uint8_t *s, int p, const uint8_t *blimit,
|
2016-02-12 07:02:53 +03:00
|
|
|
const uint8_t *limit, const uint8_t *thresh) {
|
2013-05-14 05:09:11 +04:00
|
|
|
int i;
|
2012-07-14 02:21:29 +04:00
|
|
|
|
2013-04-02 05:23:04 +04:00
|
|
|
// loop filter designed to work using chars so that we can make maximum use
|
|
|
|
// of 8 bit simd instructions.
|
2016-02-12 07:02:53 +03:00
|
|
|
for (i = 0; i < 8; ++i) {
|
2013-05-14 05:09:11 +04:00
|
|
|
const uint8_t p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p];
|
|
|
|
const uint8_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p];
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t mask =
|
|
|
|
filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3);
|
2013-07-16 03:01:31 +04:00
|
|
|
const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3);
|
2016-08-09 08:59:08 +03:00
|
|
|
filter8(mask, *thresh, flat, s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p, s,
|
|
|
|
s + 1 * p, s + 2 * p, s + 3 * p);
|
2012-07-14 02:21:29 +04:00
|
|
|
++s;
|
2013-05-14 05:09:11 +04:00
|
|
|
}
|
2010-05-18 19:58:33 +04:00
|
|
|
}
|
2012-12-19 03:31:19 +04:00
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_lpf_horizontal_8_dual_c(uint8_t *s, int p, const uint8_t *blimit0,
|
2013-12-18 05:34:34 +04:00
|
|
|
const uint8_t *limit0, const uint8_t *thresh0,
|
|
|
|
const uint8_t *blimit1, const uint8_t *limit1,
|
|
|
|
const uint8_t *thresh1) {
|
2016-02-12 07:02:53 +03:00
|
|
|
vpx_lpf_horizontal_8_c(s, p, blimit0, limit0, thresh0);
|
|
|
|
vpx_lpf_horizontal_8_c(s + 8, p, blimit1, limit1, thresh1);
|
2013-11-13 04:51:15 +04:00
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_lpf_vertical_8_c(uint8_t *s, int pitch, const uint8_t *blimit,
|
2016-02-12 06:43:36 +03:00
|
|
|
const uint8_t *limit, const uint8_t *thresh) {
|
2013-05-14 05:09:11 +04:00
|
|
|
int i;
|
|
|
|
|
2016-02-12 06:43:36 +03:00
|
|
|
for (i = 0; i < 8; ++i) {
|
2013-05-14 05:09:11 +04:00
|
|
|
const uint8_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1];
|
|
|
|
const uint8_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3];
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t mask =
|
|
|
|
filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3);
|
2013-07-16 03:01:31 +04:00
|
|
|
const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3);
|
2016-08-09 08:59:08 +03:00
|
|
|
filter8(mask, *thresh, flat, s - 4, s - 3, s - 2, s - 1, s, s + 1, s + 2,
|
|
|
|
s + 3);
|
2013-04-02 05:23:04 +04:00
|
|
|
s += pitch;
|
2013-05-14 05:09:11 +04:00
|
|
|
}
|
2010-05-18 19:58:33 +04:00
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_lpf_vertical_8_dual_c(uint8_t *s, int pitch, const uint8_t *blimit0,
|
2013-12-18 05:34:34 +04:00
|
|
|
const uint8_t *limit0, const uint8_t *thresh0,
|
|
|
|
const uint8_t *blimit1, const uint8_t *limit1,
|
|
|
|
const uint8_t *thresh1) {
|
2016-02-12 06:43:36 +03:00
|
|
|
vpx_lpf_vertical_8_c(s, pitch, blimit0, limit0, thresh0);
|
|
|
|
vpx_lpf_vertical_8_c(s + 8 * pitch, pitch, blimit1, limit1, thresh1);
|
2013-11-22 04:43:37 +04:00
|
|
|
}
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
static INLINE void filter16(int8_t mask, uint8_t thresh, uint8_t flat,
|
|
|
|
uint8_t flat2, uint8_t *op7, uint8_t *op6,
|
|
|
|
uint8_t *op5, uint8_t *op4, uint8_t *op3,
|
|
|
|
uint8_t *op2, uint8_t *op1, uint8_t *op0,
|
|
|
|
uint8_t *oq0, uint8_t *oq1, uint8_t *oq2,
|
|
|
|
uint8_t *oq3, uint8_t *oq4, uint8_t *oq5,
|
2013-07-16 03:01:31 +04:00
|
|
|
uint8_t *oq6, uint8_t *oq7) {
|
2012-12-20 03:53:03 +04:00
|
|
|
if (flat2 && flat && mask) {
|
2016-08-09 08:59:08 +03:00
|
|
|
const uint8_t p7 = *op7, p6 = *op6, p5 = *op5, p4 = *op4, p3 = *op3,
|
|
|
|
p2 = *op2, p1 = *op1, p0 = *op0;
|
2013-05-14 05:09:11 +04:00
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
const uint8_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3, q4 = *oq4,
|
|
|
|
q5 = *oq5, q6 = *oq6, q7 = *oq7;
|
2012-12-20 03:53:03 +04:00
|
|
|
|
2013-07-17 01:39:31 +04:00
|
|
|
// 15-tap filter [1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1]
|
2016-08-09 08:59:08 +03:00
|
|
|
*op6 = ROUND_POWER_OF_TWO(
|
|
|
|
p7 * 7 + p6 * 2 + p5 + p4 + p3 + p2 + p1 + p0 + q0, 4);
|
|
|
|
*op5 = ROUND_POWER_OF_TWO(
|
|
|
|
p7 * 6 + p6 + p5 * 2 + p4 + p3 + p2 + p1 + p0 + q0 + q1, 4);
|
|
|
|
*op4 = ROUND_POWER_OF_TWO(
|
|
|
|
p7 * 5 + p6 + p5 + p4 * 2 + p3 + p2 + p1 + p0 + q0 + q1 + q2, 4);
|
|
|
|
*op3 = ROUND_POWER_OF_TWO(
|
|
|
|
p7 * 4 + p6 + p5 + p4 + p3 * 2 + p2 + p1 + p0 + q0 + q1 + q2 + q3, 4);
|
|
|
|
*op2 = ROUND_POWER_OF_TWO(
|
|
|
|
p7 * 3 + p6 + p5 + p4 + p3 + p2 * 2 + p1 + p0 + q0 + q1 + q2 + q3 + q4,
|
|
|
|
4);
|
2013-04-24 22:50:49 +04:00
|
|
|
*op1 = ROUND_POWER_OF_TWO(p7 * 2 + p6 + p5 + p4 + p3 + p2 + p1 * 2 + p0 +
|
2016-08-09 08:59:08 +03:00
|
|
|
q0 + q1 + q2 + q3 + q4 + q5,
|
|
|
|
4);
|
|
|
|
*op0 = ROUND_POWER_OF_TWO(p7 + p6 + p5 + p4 + p3 + p2 + p1 + p0 * 2 + q0 +
|
|
|
|
q1 + q2 + q3 + q4 + q5 + q6,
|
|
|
|
4);
|
|
|
|
*oq0 = ROUND_POWER_OF_TWO(p6 + p5 + p4 + p3 + p2 + p1 + p0 + q0 * 2 + q1 +
|
|
|
|
q2 + q3 + q4 + q5 + q6 + q7,
|
|
|
|
4);
|
|
|
|
*oq1 = ROUND_POWER_OF_TWO(p5 + p4 + p3 + p2 + p1 + p0 + q0 + q1 * 2 + q2 +
|
|
|
|
q3 + q4 + q5 + q6 + q7 * 2,
|
|
|
|
4);
|
|
|
|
*oq2 = ROUND_POWER_OF_TWO(
|
|
|
|
p4 + p3 + p2 + p1 + p0 + q0 + q1 + q2 * 2 + q3 + q4 + q5 + q6 + q7 * 3,
|
|
|
|
4);
|
|
|
|
*oq3 = ROUND_POWER_OF_TWO(
|
|
|
|
p3 + p2 + p1 + p0 + q0 + q1 + q2 + q3 * 2 + q4 + q5 + q6 + q7 * 4, 4);
|
|
|
|
*oq4 = ROUND_POWER_OF_TWO(
|
|
|
|
p2 + p1 + p0 + q0 + q1 + q2 + q3 + q4 * 2 + q5 + q6 + q7 * 5, 4);
|
|
|
|
*oq5 = ROUND_POWER_OF_TWO(
|
|
|
|
p1 + p0 + q0 + q1 + q2 + q3 + q4 + q5 * 2 + q6 + q7 * 6, 4);
|
|
|
|
*oq6 = ROUND_POWER_OF_TWO(
|
|
|
|
p0 + q0 + q1 + q2 + q3 + q4 + q5 + q6 * 2 + q7 * 7, 4);
|
2012-12-20 03:53:03 +04:00
|
|
|
} else {
|
2013-12-18 03:23:23 +04:00
|
|
|
filter8(mask, thresh, flat, op3, op2, op1, op0, oq0, oq1, oq2, oq3);
|
2012-12-20 03:53:03 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-13 04:42:34 +03:00
|
|
|
static void mb_lpf_horizontal_edge_w(uint8_t *s, int p, const uint8_t *blimit,
|
|
|
|
const uint8_t *limit,
|
|
|
|
const uint8_t *thresh, int count) {
|
2013-05-14 05:09:11 +04:00
|
|
|
int i;
|
2012-12-20 03:53:03 +04:00
|
|
|
|
2013-04-02 05:23:04 +04:00
|
|
|
// loop filter designed to work using chars so that we can make maximum use
|
|
|
|
// of 8 bit simd instructions.
|
2013-06-13 01:37:01 +04:00
|
|
|
for (i = 0; i < 8 * count; ++i) {
|
2013-05-14 05:09:11 +04:00
|
|
|
const uint8_t p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p];
|
|
|
|
const uint8_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p];
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t mask =
|
|
|
|
filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3);
|
2013-07-16 03:01:31 +04:00
|
|
|
const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3);
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t flat2 =
|
|
|
|
flat_mask5(1, s[-8 * p], s[-7 * p], s[-6 * p], s[-5 * p], p0, q0,
|
|
|
|
s[4 * p], s[5 * p], s[6 * p], s[7 * p]);
|
|
|
|
|
|
|
|
filter16(mask, *thresh, flat, flat2, s - 8 * p, s - 7 * p, s - 6 * p,
|
|
|
|
s - 5 * p, s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p, s,
|
|
|
|
s + 1 * p, s + 2 * p, s + 3 * p, s + 4 * p, s + 5 * p, s + 6 * p,
|
|
|
|
s + 7 * p);
|
2012-12-20 03:53:03 +04:00
|
|
|
++s;
|
2013-05-14 05:09:11 +04:00
|
|
|
}
|
2012-12-20 03:53:03 +04:00
|
|
|
}
|
2013-05-14 05:09:11 +04:00
|
|
|
|
2016-02-13 04:42:34 +03:00
|
|
|
void vpx_lpf_horizontal_edge_8_c(uint8_t *s, int p, const uint8_t *blimit,
|
|
|
|
const uint8_t *limit, const uint8_t *thresh) {
|
|
|
|
mb_lpf_horizontal_edge_w(s, p, blimit, limit, thresh, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vpx_lpf_horizontal_edge_16_c(uint8_t *s, int p, const uint8_t *blimit,
|
|
|
|
const uint8_t *limit, const uint8_t *thresh) {
|
|
|
|
mb_lpf_horizontal_edge_w(s, p, blimit, limit, thresh, 2);
|
|
|
|
}
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
static void mb_lpf_vertical_edge_w(uint8_t *s, int p, const uint8_t *blimit,
|
|
|
|
const uint8_t *limit, const uint8_t *thresh,
|
2013-12-06 03:49:57 +04:00
|
|
|
int count) {
|
2013-05-14 05:09:11 +04:00
|
|
|
int i;
|
|
|
|
|
2013-12-06 03:49:57 +04:00
|
|
|
for (i = 0; i < count; ++i) {
|
2013-05-14 05:09:11 +04:00
|
|
|
const uint8_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1];
|
2016-08-09 08:59:08 +03:00
|
|
|
const uint8_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3];
|
|
|
|
const int8_t mask =
|
|
|
|
filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3);
|
2013-07-16 03:01:31 +04:00
|
|
|
const int8_t flat = flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3);
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t flat2 = flat_mask5(1, s[-8], s[-7], s[-6], s[-5], p0, q0, s[4],
|
|
|
|
s[5], s[6], s[7]);
|
2012-12-20 03:53:03 +04:00
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
filter16(mask, *thresh, flat, flat2, s - 8, s - 7, s - 6, s - 5, s - 4,
|
|
|
|
s - 3, s - 2, s - 1, s, s + 1, s + 2, s + 3, s + 4, s + 5, s + 6,
|
|
|
|
s + 7);
|
2012-12-20 03:53:03 +04:00
|
|
|
s += p;
|
2013-05-14 05:09:11 +04:00
|
|
|
}
|
2012-12-20 03:53:03 +04:00
|
|
|
}
|
2013-11-22 04:43:37 +04:00
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_lpf_vertical_16_c(uint8_t *s, int p, const uint8_t *blimit,
|
2013-12-18 05:34:34 +04:00
|
|
|
const uint8_t *limit, const uint8_t *thresh) {
|
2013-12-06 03:49:57 +04:00
|
|
|
mb_lpf_vertical_edge_w(s, p, blimit, limit, thresh, 8);
|
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_lpf_vertical_16_dual_c(uint8_t *s, int p, const uint8_t *blimit,
|
2013-12-18 05:34:34 +04:00
|
|
|
const uint8_t *limit, const uint8_t *thresh) {
|
2013-12-06 03:49:57 +04:00
|
|
|
mb_lpf_vertical_edge_w(s, p, blimit, limit, thresh, 16);
|
2013-11-22 04:43:37 +04:00
|
|
|
}
|
2014-09-18 03:55:05 +04:00
|
|
|
|
|
|
|
#if CONFIG_VP9_HIGHBITDEPTH
|
|
|
|
// Should we apply any filter at all: 11111111 yes, 00000000 no ?
|
2014-10-08 23:43:22 +04:00
|
|
|
static INLINE int8_t highbd_filter_mask(uint8_t limit, uint8_t blimit,
|
2016-08-09 08:59:08 +03:00
|
|
|
uint16_t p3, uint16_t p2, uint16_t p1,
|
|
|
|
uint16_t p0, uint16_t q0, uint16_t q1,
|
2014-10-08 23:43:22 +04:00
|
|
|
uint16_t q2, uint16_t q3, int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
int8_t mask = 0;
|
|
|
|
int16_t limit16 = (uint16_t)limit << (bd - 8);
|
|
|
|
int16_t blimit16 = (uint16_t)blimit << (bd - 8);
|
|
|
|
mask |= (abs(p3 - p2) > limit16) * -1;
|
|
|
|
mask |= (abs(p2 - p1) > limit16) * -1;
|
|
|
|
mask |= (abs(p1 - p0) > limit16) * -1;
|
|
|
|
mask |= (abs(q1 - q0) > limit16) * -1;
|
|
|
|
mask |= (abs(q2 - q1) > limit16) * -1;
|
|
|
|
mask |= (abs(q3 - q2) > limit16) * -1;
|
2016-08-09 08:59:08 +03:00
|
|
|
mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2 > blimit16) * -1;
|
2014-09-18 03:55:05 +04:00
|
|
|
return ~mask;
|
|
|
|
}
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
static INLINE int8_t highbd_flat_mask4(uint8_t thresh, uint16_t p3, uint16_t p2,
|
|
|
|
uint16_t p1, uint16_t p0, uint16_t q0,
|
|
|
|
uint16_t q1, uint16_t q2, uint16_t q3,
|
|
|
|
int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
int8_t mask = 0;
|
|
|
|
int16_t thresh16 = (uint16_t)thresh << (bd - 8);
|
|
|
|
mask |= (abs(p1 - p0) > thresh16) * -1;
|
|
|
|
mask |= (abs(q1 - q0) > thresh16) * -1;
|
|
|
|
mask |= (abs(p2 - p0) > thresh16) * -1;
|
|
|
|
mask |= (abs(q2 - q0) > thresh16) * -1;
|
|
|
|
mask |= (abs(p3 - p0) > thresh16) * -1;
|
|
|
|
mask |= (abs(q3 - q0) > thresh16) * -1;
|
|
|
|
return ~mask;
|
|
|
|
}
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
static INLINE int8_t highbd_flat_mask5(uint8_t thresh, uint16_t p4, uint16_t p3,
|
|
|
|
uint16_t p2, uint16_t p1, uint16_t p0,
|
|
|
|
uint16_t q0, uint16_t q1, uint16_t q2,
|
2014-10-08 23:43:22 +04:00
|
|
|
uint16_t q3, uint16_t q4, int bd) {
|
|
|
|
int8_t mask = ~highbd_flat_mask4(thresh, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
int16_t thresh16 = (uint16_t)thresh << (bd - 8);
|
|
|
|
mask |= (abs(p4 - p0) > thresh16) * -1;
|
|
|
|
mask |= (abs(q4 - q0) > thresh16) * -1;
|
|
|
|
return ~mask;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Is there high edge variance internal edge:
|
|
|
|
// 11111111_11111111 yes, 00000000_00000000 no ?
|
2014-10-08 23:43:22 +04:00
|
|
|
static INLINE int16_t highbd_hev_mask(uint8_t thresh, uint16_t p1, uint16_t p0,
|
|
|
|
uint16_t q0, uint16_t q1, int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
int16_t hev = 0;
|
|
|
|
int16_t thresh16 = (uint16_t)thresh << (bd - 8);
|
|
|
|
hev |= (abs(p1 - p0) > thresh16) * -1;
|
|
|
|
hev |= (abs(q1 - q0) > thresh16) * -1;
|
|
|
|
return hev;
|
|
|
|
}
|
|
|
|
|
2014-10-08 23:43:22 +04:00
|
|
|
static INLINE void highbd_filter4(int8_t mask, uint8_t thresh, uint16_t *op1,
|
|
|
|
uint16_t *op0, uint16_t *oq0, uint16_t *oq1,
|
|
|
|
int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
int16_t filter1, filter2;
|
|
|
|
// ^0x80 equivalent to subtracting 0x80 from the values to turn them
|
|
|
|
// into -128 to +127 instead of 0 to 255.
|
|
|
|
int shift = bd - 8;
|
|
|
|
const int16_t ps1 = (int16_t)*op1 - (0x80 << shift);
|
|
|
|
const int16_t ps0 = (int16_t)*op0 - (0x80 << shift);
|
|
|
|
const int16_t qs0 = (int16_t)*oq0 - (0x80 << shift);
|
|
|
|
const int16_t qs1 = (int16_t)*oq1 - (0x80 << shift);
|
2014-10-08 23:43:22 +04:00
|
|
|
const uint16_t hev = highbd_hev_mask(thresh, *op1, *op0, *oq0, *oq1, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
|
|
|
|
// Add outer taps if we have high edge variance.
|
|
|
|
int16_t filter = signed_char_clamp_high(ps1 - qs1, bd) & hev;
|
|
|
|
|
|
|
|
// Inner taps.
|
|
|
|
filter = signed_char_clamp_high(filter + 3 * (qs0 - ps0), bd) & mask;
|
|
|
|
|
|
|
|
// Save bottom 3 bits so that we round one side +4 and the other +3
|
|
|
|
// if it equals 4 we'll set to adjust by -1 to account for the fact
|
|
|
|
// we'd round 3 the other way.
|
|
|
|
filter1 = signed_char_clamp_high(filter + 4, bd) >> 3;
|
|
|
|
filter2 = signed_char_clamp_high(filter + 3, bd) >> 3;
|
|
|
|
|
|
|
|
*oq0 = signed_char_clamp_high(qs0 - filter1, bd) + (0x80 << shift);
|
|
|
|
*op0 = signed_char_clamp_high(ps0 + filter2, bd) + (0x80 << shift);
|
|
|
|
|
|
|
|
// Outer tap adjustments.
|
|
|
|
filter = ROUND_POWER_OF_TWO(filter1, 1) & ~hev;
|
|
|
|
|
|
|
|
*oq1 = signed_char_clamp_high(qs1 - filter, bd) + (0x80 << shift);
|
|
|
|
*op1 = signed_char_clamp_high(ps1 + filter, bd) + (0x80 << shift);
|
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_highbd_lpf_horizontal_4_c(uint16_t *s, int p /* pitch */,
|
2014-09-18 03:55:05 +04:00
|
|
|
const uint8_t *blimit, const uint8_t *limit,
|
2016-02-12 07:59:39 +03:00
|
|
|
const uint8_t *thresh, int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
// loop filter designed to work using chars so that we can make maximum use
|
|
|
|
// of 8 bit simd instructions.
|
2016-02-12 07:59:39 +03:00
|
|
|
for (i = 0; i < 8; ++i) {
|
2014-09-18 03:55:05 +04:00
|
|
|
const uint16_t p3 = s[-4 * p];
|
|
|
|
const uint16_t p2 = s[-3 * p];
|
|
|
|
const uint16_t p1 = s[-2 * p];
|
|
|
|
const uint16_t p0 = s[-p];
|
|
|
|
const uint16_t q0 = s[0 * p];
|
|
|
|
const uint16_t q1 = s[1 * p];
|
|
|
|
const uint16_t q2 = s[2 * p];
|
|
|
|
const uint16_t q3 = s[3 * p];
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t mask =
|
|
|
|
highbd_filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
2014-10-08 23:43:22 +04:00
|
|
|
highbd_filter4(mask, *thresh, s - 2 * p, s - 1 * p, s, s + 1 * p, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
++s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
void vpx_highbd_lpf_horizontal_4_dual_c(
|
|
|
|
uint16_t *s, int p, const uint8_t *blimit0, const uint8_t *limit0,
|
|
|
|
const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1,
|
|
|
|
const uint8_t *thresh1, int bd) {
|
2016-02-12 07:59:39 +03:00
|
|
|
vpx_highbd_lpf_horizontal_4_c(s, p, blimit0, limit0, thresh0, bd);
|
|
|
|
vpx_highbd_lpf_horizontal_4_c(s + 8, p, blimit1, limit1, thresh1, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_highbd_lpf_vertical_4_c(uint16_t *s, int pitch, const uint8_t *blimit,
|
2014-09-18 03:55:05 +04:00
|
|
|
const uint8_t *limit, const uint8_t *thresh,
|
2016-02-12 07:50:42 +03:00
|
|
|
int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
// loop filter designed to work using chars so that we can make maximum use
|
|
|
|
// of 8 bit simd instructions.
|
2016-02-12 07:50:42 +03:00
|
|
|
for (i = 0; i < 8; ++i) {
|
2014-09-18 03:55:05 +04:00
|
|
|
const uint16_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1];
|
2016-08-09 08:59:08 +03:00
|
|
|
const uint16_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3];
|
|
|
|
const int8_t mask =
|
|
|
|
highbd_filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
2014-10-08 23:43:22 +04:00
|
|
|
highbd_filter4(mask, *thresh, s - 2, s - 1, s, s + 1, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
s += pitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
void vpx_highbd_lpf_vertical_4_dual_c(
|
|
|
|
uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0,
|
|
|
|
const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1,
|
|
|
|
const uint8_t *thresh1, int bd) {
|
2016-02-12 07:50:42 +03:00
|
|
|
vpx_highbd_lpf_vertical_4_c(s, pitch, blimit0, limit0, thresh0, bd);
|
2016-08-09 08:59:08 +03:00
|
|
|
vpx_highbd_lpf_vertical_4_c(s + 8 * pitch, pitch, blimit1, limit1, thresh1,
|
|
|
|
bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
}
|
|
|
|
|
2014-10-08 23:43:22 +04:00
|
|
|
static INLINE void highbd_filter8(int8_t mask, uint8_t thresh, uint8_t flat,
|
2016-08-09 08:59:08 +03:00
|
|
|
uint16_t *op3, uint16_t *op2, uint16_t *op1,
|
|
|
|
uint16_t *op0, uint16_t *oq0, uint16_t *oq1,
|
2014-10-08 23:43:22 +04:00
|
|
|
uint16_t *oq2, uint16_t *oq3, int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
if (flat && mask) {
|
|
|
|
const uint16_t p3 = *op3, p2 = *op2, p1 = *op1, p0 = *op0;
|
|
|
|
const uint16_t q0 = *oq0, q1 = *oq1, q2 = *oq2, q3 = *oq3;
|
|
|
|
|
|
|
|
// 7-tap filter [1, 1, 1, 2, 1, 1, 1]
|
|
|
|
*op2 = ROUND_POWER_OF_TWO(p3 + p3 + p3 + 2 * p2 + p1 + p0 + q0, 3);
|
|
|
|
*op1 = ROUND_POWER_OF_TWO(p3 + p3 + p2 + 2 * p1 + p0 + q0 + q1, 3);
|
|
|
|
*op0 = ROUND_POWER_OF_TWO(p3 + p2 + p1 + 2 * p0 + q0 + q1 + q2, 3);
|
|
|
|
*oq0 = ROUND_POWER_OF_TWO(p2 + p1 + p0 + 2 * q0 + q1 + q2 + q3, 3);
|
|
|
|
*oq1 = ROUND_POWER_OF_TWO(p1 + p0 + q0 + 2 * q1 + q2 + q3 + q3, 3);
|
|
|
|
*oq2 = ROUND_POWER_OF_TWO(p0 + q0 + q1 + 2 * q2 + q3 + q3 + q3, 3);
|
|
|
|
} else {
|
2016-08-09 08:59:08 +03:00
|
|
|
highbd_filter4(mask, thresh, op1, op0, oq0, oq1, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_highbd_lpf_horizontal_8_c(uint16_t *s, int p, const uint8_t *blimit,
|
2014-09-18 03:55:05 +04:00
|
|
|
const uint8_t *limit, const uint8_t *thresh,
|
2016-02-12 07:54:16 +03:00
|
|
|
int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
// loop filter designed to work using chars so that we can make maximum use
|
|
|
|
// of 8 bit simd instructions.
|
2016-02-12 07:54:16 +03:00
|
|
|
for (i = 0; i < 8; ++i) {
|
2014-09-18 03:55:05 +04:00
|
|
|
const uint16_t p3 = s[-4 * p], p2 = s[-3 * p], p1 = s[-2 * p], p0 = s[-p];
|
|
|
|
const uint16_t q0 = s[0 * p], q1 = s[1 * p], q2 = s[2 * p], q3 = s[3 * p];
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t mask =
|
|
|
|
highbd_filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
|
|
|
const int8_t flat =
|
|
|
|
highbd_flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
|
|
|
highbd_filter8(mask, *thresh, flat, s - 4 * p, s - 3 * p, s - 2 * p,
|
|
|
|
s - 1 * p, s, s + 1 * p, s + 2 * p, s + 3 * p, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
++s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
void vpx_highbd_lpf_horizontal_8_dual_c(
|
|
|
|
uint16_t *s, int p, const uint8_t *blimit0, const uint8_t *limit0,
|
|
|
|
const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1,
|
|
|
|
const uint8_t *thresh1, int bd) {
|
2016-02-12 07:54:16 +03:00
|
|
|
vpx_highbd_lpf_horizontal_8_c(s, p, blimit0, limit0, thresh0, bd);
|
|
|
|
vpx_highbd_lpf_horizontal_8_c(s + 8, p, blimit1, limit1, thresh1, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_highbd_lpf_vertical_8_c(uint16_t *s, int pitch, const uint8_t *blimit,
|
2014-09-18 03:55:05 +04:00
|
|
|
const uint8_t *limit, const uint8_t *thresh,
|
2016-02-12 07:49:56 +03:00
|
|
|
int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
int i;
|
|
|
|
|
2016-02-12 07:49:56 +03:00
|
|
|
for (i = 0; i < 8; ++i) {
|
2014-09-18 03:55:05 +04:00
|
|
|
const uint16_t p3 = s[-4], p2 = s[-3], p1 = s[-2], p0 = s[-1];
|
|
|
|
const uint16_t q0 = s[0], q1 = s[1], q2 = s[2], q3 = s[3];
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t mask =
|
|
|
|
highbd_filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
|
|
|
const int8_t flat =
|
|
|
|
highbd_flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
|
|
|
highbd_filter8(mask, *thresh, flat, s - 4, s - 3, s - 2, s - 1, s, s + 1,
|
|
|
|
s + 2, s + 3, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
s += pitch;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
void vpx_highbd_lpf_vertical_8_dual_c(
|
|
|
|
uint16_t *s, int pitch, const uint8_t *blimit0, const uint8_t *limit0,
|
|
|
|
const uint8_t *thresh0, const uint8_t *blimit1, const uint8_t *limit1,
|
|
|
|
const uint8_t *thresh1, int bd) {
|
2016-02-12 07:49:56 +03:00
|
|
|
vpx_highbd_lpf_vertical_8_c(s, pitch, blimit0, limit0, thresh0, bd);
|
2016-08-09 08:59:08 +03:00
|
|
|
vpx_highbd_lpf_vertical_8_c(s + 8 * pitch, pitch, blimit1, limit1, thresh1,
|
|
|
|
bd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static INLINE void highbd_filter16(int8_t mask, uint8_t thresh, uint8_t flat,
|
|
|
|
uint8_t flat2, uint16_t *op7, uint16_t *op6,
|
|
|
|
uint16_t *op5, uint16_t *op4, uint16_t *op3,
|
|
|
|
uint16_t *op2, uint16_t *op1, uint16_t *op0,
|
|
|
|
uint16_t *oq0, uint16_t *oq1, uint16_t *oq2,
|
|
|
|
uint16_t *oq3, uint16_t *oq4, uint16_t *oq5,
|
2014-10-08 23:43:22 +04:00
|
|
|
uint16_t *oq6, uint16_t *oq7, int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
if (flat2 && flat && mask) {
|
|
|
|
const uint16_t p7 = *op7;
|
|
|
|
const uint16_t p6 = *op6;
|
|
|
|
const uint16_t p5 = *op5;
|
|
|
|
const uint16_t p4 = *op4;
|
|
|
|
const uint16_t p3 = *op3;
|
|
|
|
const uint16_t p2 = *op2;
|
|
|
|
const uint16_t p1 = *op1;
|
|
|
|
const uint16_t p0 = *op0;
|
|
|
|
const uint16_t q0 = *oq0;
|
|
|
|
const uint16_t q1 = *oq1;
|
|
|
|
const uint16_t q2 = *oq2;
|
|
|
|
const uint16_t q3 = *oq3;
|
|
|
|
const uint16_t q4 = *oq4;
|
|
|
|
const uint16_t q5 = *oq5;
|
|
|
|
const uint16_t q6 = *oq6;
|
|
|
|
const uint16_t q7 = *oq7;
|
|
|
|
|
|
|
|
// 15-tap filter [1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1]
|
2016-08-09 08:59:08 +03:00
|
|
|
*op6 = ROUND_POWER_OF_TWO(
|
|
|
|
p7 * 7 + p6 * 2 + p5 + p4 + p3 + p2 + p1 + p0 + q0, 4);
|
|
|
|
*op5 = ROUND_POWER_OF_TWO(
|
|
|
|
p7 * 6 + p6 + p5 * 2 + p4 + p3 + p2 + p1 + p0 + q0 + q1, 4);
|
|
|
|
*op4 = ROUND_POWER_OF_TWO(
|
|
|
|
p7 * 5 + p6 + p5 + p4 * 2 + p3 + p2 + p1 + p0 + q0 + q1 + q2, 4);
|
|
|
|
*op3 = ROUND_POWER_OF_TWO(
|
|
|
|
p7 * 4 + p6 + p5 + p4 + p3 * 2 + p2 + p1 + p0 + q0 + q1 + q2 + q3, 4);
|
|
|
|
*op2 = ROUND_POWER_OF_TWO(
|
|
|
|
p7 * 3 + p6 + p5 + p4 + p3 + p2 * 2 + p1 + p0 + q0 + q1 + q2 + q3 + q4,
|
|
|
|
4);
|
2014-09-18 03:55:05 +04:00
|
|
|
*op1 = ROUND_POWER_OF_TWO(p7 * 2 + p6 + p5 + p4 + p3 + p2 + p1 * 2 + p0 +
|
2016-08-09 08:59:08 +03:00
|
|
|
q0 + q1 + q2 + q3 + q4 + q5,
|
|
|
|
4);
|
|
|
|
*op0 = ROUND_POWER_OF_TWO(p7 + p6 + p5 + p4 + p3 + p2 + p1 + p0 * 2 + q0 +
|
|
|
|
q1 + q2 + q3 + q4 + q5 + q6,
|
|
|
|
4);
|
|
|
|
*oq0 = ROUND_POWER_OF_TWO(p6 + p5 + p4 + p3 + p2 + p1 + p0 + q0 * 2 + q1 +
|
|
|
|
q2 + q3 + q4 + q5 + q6 + q7,
|
|
|
|
4);
|
|
|
|
*oq1 = ROUND_POWER_OF_TWO(p5 + p4 + p3 + p2 + p1 + p0 + q0 + q1 * 2 + q2 +
|
|
|
|
q3 + q4 + q5 + q6 + q7 * 2,
|
|
|
|
4);
|
|
|
|
*oq2 = ROUND_POWER_OF_TWO(
|
|
|
|
p4 + p3 + p2 + p1 + p0 + q0 + q1 + q2 * 2 + q3 + q4 + q5 + q6 + q7 * 3,
|
|
|
|
4);
|
|
|
|
*oq3 = ROUND_POWER_OF_TWO(
|
|
|
|
p3 + p2 + p1 + p0 + q0 + q1 + q2 + q3 * 2 + q4 + q5 + q6 + q7 * 4, 4);
|
|
|
|
*oq4 = ROUND_POWER_OF_TWO(
|
|
|
|
p2 + p1 + p0 + q0 + q1 + q2 + q3 + q4 * 2 + q5 + q6 + q7 * 5, 4);
|
|
|
|
*oq5 = ROUND_POWER_OF_TWO(
|
|
|
|
p1 + p0 + q0 + q1 + q2 + q3 + q4 + q5 * 2 + q6 + q7 * 6, 4);
|
|
|
|
*oq6 = ROUND_POWER_OF_TWO(
|
|
|
|
p0 + q0 + q1 + q2 + q3 + q4 + q5 + q6 * 2 + q7 * 7, 4);
|
2014-09-18 03:55:05 +04:00
|
|
|
} else {
|
2014-10-08 23:43:22 +04:00
|
|
|
highbd_filter8(mask, thresh, flat, op3, op2, op1, op0, oq0, oq1, oq2, oq3,
|
|
|
|
bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-13 05:12:57 +03:00
|
|
|
static void highbd_mb_lpf_horizontal_edge_w(uint16_t *s, int p,
|
|
|
|
const uint8_t *blimit,
|
|
|
|
const uint8_t *limit,
|
2016-08-09 08:59:08 +03:00
|
|
|
const uint8_t *thresh, int count,
|
|
|
|
int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
// loop filter designed to work using chars so that we can make maximum use
|
|
|
|
// of 8 bit simd instructions.
|
|
|
|
for (i = 0; i < 8 * count; ++i) {
|
|
|
|
const uint16_t p3 = s[-4 * p];
|
|
|
|
const uint16_t p2 = s[-3 * p];
|
|
|
|
const uint16_t p1 = s[-2 * p];
|
|
|
|
const uint16_t p0 = s[-p];
|
|
|
|
const uint16_t q0 = s[0 * p];
|
|
|
|
const uint16_t q1 = s[1 * p];
|
|
|
|
const uint16_t q2 = s[2 * p];
|
|
|
|
const uint16_t q3 = s[3 * p];
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t mask =
|
|
|
|
highbd_filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
|
|
|
const int8_t flat =
|
|
|
|
highbd_flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
|
|
|
const int8_t flat2 =
|
|
|
|
highbd_flat_mask5(1, s[-8 * p], s[-7 * p], s[-6 * p], s[-5 * p], p0, q0,
|
|
|
|
s[4 * p], s[5 * p], s[6 * p], s[7 * p], bd);
|
|
|
|
|
|
|
|
highbd_filter16(mask, *thresh, flat, flat2, s - 8 * p, s - 7 * p, s - 6 * p,
|
|
|
|
s - 5 * p, s - 4 * p, s - 3 * p, s - 2 * p, s - 1 * p, s,
|
|
|
|
s + 1 * p, s + 2 * p, s + 3 * p, s + 4 * p, s + 5 * p,
|
|
|
|
s + 6 * p, s + 7 * p, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
++s;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-13 05:12:57 +03:00
|
|
|
void vpx_highbd_lpf_horizontal_edge_8_c(uint16_t *s, int p,
|
|
|
|
const uint8_t *blimit,
|
|
|
|
const uint8_t *limit,
|
|
|
|
const uint8_t *thresh, int bd) {
|
|
|
|
highbd_mb_lpf_horizontal_edge_w(s, p, blimit, limit, thresh, 1, bd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vpx_highbd_lpf_horizontal_edge_16_c(uint16_t *s, int p,
|
|
|
|
const uint8_t *blimit,
|
|
|
|
const uint8_t *limit,
|
|
|
|
const uint8_t *thresh, int bd) {
|
|
|
|
highbd_mb_lpf_horizontal_edge_w(s, p, blimit, limit, thresh, 2, bd);
|
|
|
|
}
|
|
|
|
|
2014-10-08 23:43:22 +04:00
|
|
|
static void highbd_mb_lpf_vertical_edge_w(uint16_t *s, int p,
|
|
|
|
const uint8_t *blimit,
|
|
|
|
const uint8_t *limit,
|
2016-08-09 08:59:08 +03:00
|
|
|
const uint8_t *thresh, int count,
|
|
|
|
int bd) {
|
2014-09-18 03:55:05 +04:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; ++i) {
|
|
|
|
const uint16_t p3 = s[-4];
|
|
|
|
const uint16_t p2 = s[-3];
|
|
|
|
const uint16_t p1 = s[-2];
|
|
|
|
const uint16_t p0 = s[-1];
|
|
|
|
const uint16_t q0 = s[0];
|
|
|
|
const uint16_t q1 = s[1];
|
|
|
|
const uint16_t q2 = s[2];
|
|
|
|
const uint16_t q3 = s[3];
|
2016-08-09 08:59:08 +03:00
|
|
|
const int8_t mask =
|
|
|
|
highbd_filter_mask(*limit, *blimit, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
|
|
|
const int8_t flat =
|
|
|
|
highbd_flat_mask4(1, p3, p2, p1, p0, q0, q1, q2, q3, bd);
|
2014-10-08 23:43:22 +04:00
|
|
|
const int8_t flat2 = highbd_flat_mask5(1, s[-8], s[-7], s[-6], s[-5], p0,
|
|
|
|
q0, s[4], s[5], s[6], s[7], bd);
|
|
|
|
|
2016-08-09 08:59:08 +03:00
|
|
|
highbd_filter16(mask, *thresh, flat, flat2, s - 8, s - 7, s - 6, s - 5,
|
|
|
|
s - 4, s - 3, s - 2, s - 1, s, s + 1, s + 2, s + 3, s + 4,
|
|
|
|
s + 5, s + 6, s + 7, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
s += p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_highbd_lpf_vertical_16_c(uint16_t *s, int p, const uint8_t *blimit,
|
2014-09-18 03:55:05 +04:00
|
|
|
const uint8_t *limit, const uint8_t *thresh,
|
|
|
|
int bd) {
|
2014-10-08 23:43:22 +04:00
|
|
|
highbd_mb_lpf_vertical_edge_w(s, p, blimit, limit, thresh, 8, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
}
|
|
|
|
|
2015-07-17 22:31:53 +03:00
|
|
|
void vpx_highbd_lpf_vertical_16_dual_c(uint16_t *s, int p,
|
2014-09-18 03:55:05 +04:00
|
|
|
const uint8_t *blimit,
|
|
|
|
const uint8_t *limit,
|
2016-08-09 08:59:08 +03:00
|
|
|
const uint8_t *thresh, int bd) {
|
2014-10-08 23:43:22 +04:00
|
|
|
highbd_mb_lpf_vertical_edge_w(s, p, blimit, limit, thresh, 16, bd);
|
2014-09-18 03:55:05 +04:00
|
|
|
}
|
|
|
|
#endif // CONFIG_VP9_HIGHBITDEPTH
|