mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-16 12:17:34 +09:00
Update libaom to commit ID 1e227d41f0616de9548a673a83a21ef990b62591
This commit is contained in:
parent
77c9089b7d
commit
368651059a
526 changed files with 34535 additions and 15900 deletions
7
third_party/aom/av1/encoder/aq_complexity.c
vendored
7
third_party/aom/av1/encoder/aq_complexity.c
vendored
|
|
@ -143,9 +143,10 @@ void av1_caq_select_segment(const AV1_COMP *cpi, MACROBLOCK *mb, BLOCK_SIZE bs,
|
|||
get_aq_c_strength(cm->base_qindex, cm->seq_params.bit_depth);
|
||||
|
||||
aom_clear_system_state();
|
||||
low_var_thresh = (cpi->oxcf.pass == 2) ? AOMMAX(cpi->twopass.mb_av_energy,
|
||||
MIN_DEFAULT_LV_THRESH)
|
||||
: DEFAULT_LV_THRESH;
|
||||
low_var_thresh =
|
||||
(cpi->oxcf.pass == 2)
|
||||
? AOMMAX(exp(cpi->twopass.mb_av_energy), MIN_DEFAULT_LV_THRESH)
|
||||
: DEFAULT_LV_THRESH;
|
||||
|
||||
av1_setup_src_planes(mb, cpi->source, mi_row, mi_col, num_planes);
|
||||
logvar = av1_log_block_var(cpi, mb, bs);
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/aq_complexity.h
vendored
6
third_party/aom/av1/encoder/aq_complexity.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_AQ_COMPLEXITY_H_
|
||||
#define AV1_ENCODER_AQ_COMPLEXITY_H_
|
||||
#ifndef AOM_AV1_ENCODER_AQ_COMPLEXITY_H_
|
||||
#define AOM_AV1_ENCODER_AQ_COMPLEXITY_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -34,4 +34,4 @@ void av1_setup_in_frame_q_adj(struct AV1_COMP *cpi);
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_AQ_COMPLEXITY_H_
|
||||
#endif // AOM_AV1_ENCODER_AQ_COMPLEXITY_H_
|
||||
|
|
|
|||
|
|
@ -80,9 +80,11 @@ CYCLIC_REFRESH *av1_cyclic_refresh_alloc(int mi_rows, int mi_cols) {
|
|||
}
|
||||
|
||||
void av1_cyclic_refresh_free(CYCLIC_REFRESH *cr) {
|
||||
aom_free(cr->map);
|
||||
aom_free(cr->last_coded_q_map);
|
||||
aom_free(cr);
|
||||
if (cr != NULL) {
|
||||
aom_free(cr->map);
|
||||
aom_free(cr->last_coded_q_map);
|
||||
aom_free(cr);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we should turn off cyclic refresh based on bitrate condition.
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_AQ_CYCLICREFRESH_H_
|
||||
#define AV1_ENCODER_AQ_CYCLICREFRESH_H_
|
||||
#ifndef AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_
|
||||
#define AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_
|
||||
|
||||
#include "av1/common/blockd.h"
|
||||
|
||||
|
|
@ -95,4 +95,4 @@ static INLINE int cyclic_refresh_segment_id(int segment_id) {
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_AQ_CYCLICREFRESH_H_
|
||||
#endif // AOM_AV1_ENCODER_AQ_CYCLICREFRESH_H_
|
||||
|
|
|
|||
185
third_party/aom/av1/encoder/aq_variance.c
vendored
185
third_party/aom/av1/encoder/aq_variance.c
vendored
|
|
@ -14,34 +14,33 @@
|
|||
#include "aom_ports/mem.h"
|
||||
|
||||
#include "av1/encoder/aq_variance.h"
|
||||
|
||||
#include "av1/common/seg_common.h"
|
||||
#include "av1/encoder/encodeframe.h"
|
||||
#include "av1/encoder/ratectrl.h"
|
||||
#include "av1/encoder/rd.h"
|
||||
#include "av1/encoder/segmentation.h"
|
||||
#include "av1/encoder/dwt.h"
|
||||
#include "aom_ports/system_state.h"
|
||||
|
||||
static const double rate_ratio[MAX_SEGMENTS] = { 2.2, 1.7, 1.3, 1.0,
|
||||
0.9, .8, .7, .6 };
|
||||
|
||||
static const double deltaq_rate_ratio[MAX_SEGMENTS] = { 2.5, 2.0, 1.5, 1.0,
|
||||
0.75, 1.0, 1.0, 1.0 };
|
||||
#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] = { 2.5, 2.0, 1.5, 1.0,
|
||||
0.75, 1.0, 1.0, 1.0 };
|
||||
static const int segment_id[ENERGY_SPAN] = { 0, 1, 1, 2, 3, 4 };
|
||||
|
||||
#define SEGMENT_ID(i) segment_id[(i)-ENERGY_MIN]
|
||||
|
||||
DECLARE_ALIGNED(16, static const uint8_t, av1_all_zeros[MAX_SB_SIZE]) = { 0 };
|
||||
|
||||
DECLARE_ALIGNED(16, static const uint16_t,
|
||||
av1_highbd_all_zeros[MAX_SB_SIZE]) = { 0 };
|
||||
|
||||
unsigned int av1_vaq_segment_id(int energy) {
|
||||
ENERGY_IN_BOUNDS(energy);
|
||||
return SEGMENT_ID(energy);
|
||||
}
|
||||
static const int segment_id[ENERGY_SPAN] = { 0, 1, 1, 2, 3, 4 };
|
||||
|
||||
#define SEGMENT_ID(i) segment_id[(i)-ENERGY_MIN]
|
||||
|
||||
void av1_vaq_frame_setup(AV1_COMP *cpi) {
|
||||
AV1_COMMON *cm = &cpi->common;
|
||||
|
|
@ -51,6 +50,12 @@ void av1_vaq_frame_setup(AV1_COMP *cpi) {
|
|||
int resolution_change =
|
||||
cm->prev_frame && (cm->width != cm->prev_frame->width ||
|
||||
cm->height != cm->prev_frame->height);
|
||||
int avg_energy = (int)(cpi->twopass.mb_av_energy - 2);
|
||||
double avg_ratio;
|
||||
if (avg_energy > 7) avg_energy = 7;
|
||||
if (avg_energy < 0) avg_energy = 0;
|
||||
avg_ratio = rate_ratio[avg_energy];
|
||||
|
||||
if (resolution_change) {
|
||||
memset(cpi->segmentation_map, 0, cm->mi_rows * cm->mi_cols);
|
||||
av1_clearall_segfeatures(seg);
|
||||
|
|
@ -69,9 +74,11 @@ void av1_vaq_frame_setup(AV1_COMP *cpi) {
|
|||
aom_clear_system_state();
|
||||
|
||||
for (i = 0; i < MAX_SEGMENTS; ++i) {
|
||||
int qindex_delta =
|
||||
av1_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex,
|
||||
rate_ratio[i], cm->seq_params.bit_depth);
|
||||
// Set up avg segment id to be 1.0 and adjust the other segments around
|
||||
// it.
|
||||
int qindex_delta = av1_compute_qdelta_by_rate(
|
||||
&cpi->rc, cm->frame_type, cm->base_qindex, rate_ratio[i] / avg_ratio,
|
||||
cm->seq_params.bit_depth);
|
||||
|
||||
// We don't allow qindex 0 in a segment if the base value is not 0.
|
||||
// Q index 0 (lossless) implies 4x4 encoding only and in AQ mode a segment
|
||||
|
|
@ -87,114 +94,58 @@ void av1_vaq_frame_setup(AV1_COMP *cpi) {
|
|||
}
|
||||
}
|
||||
|
||||
/* TODO(agrange, paulwilkins): The block_variance calls the unoptimized versions
|
||||
* of variance() and highbd_8_variance(). It should not.
|
||||
*/
|
||||
static void aq_variance(const uint8_t *a, int a_stride, const uint8_t *b,
|
||||
int b_stride, int w, int h, unsigned int *sse,
|
||||
int *sum) {
|
||||
int i, j;
|
||||
int av1_log_block_var(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) {
|
||||
// This functions returns a score for the blocks local variance as calculated
|
||||
// by: sum of the log of the (4x4 variances) of each subblock to the current
|
||||
// block (x,bs)
|
||||
// * 32 / number of pixels in the block_size.
|
||||
// This is used for segmentation because to avoid situations in which a large
|
||||
// block with a gentle gradient gets marked high variance even though each
|
||||
// subblock has a low variance. This allows us to assign the same segment
|
||||
// number for the same sorts of area regardless of how the partitioning goes.
|
||||
|
||||
*sum = 0;
|
||||
*sse = 0;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
const int diff = a[j] - b[j];
|
||||
*sum += diff;
|
||||
*sse += diff * diff;
|
||||
}
|
||||
|
||||
a += a_stride;
|
||||
b += b_stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void aq_highbd_variance64(const uint8_t *a8, int a_stride,
|
||||
const uint8_t *b8, int b_stride, int w, int h,
|
||||
uint64_t *sse, uint64_t *sum) {
|
||||
int i, j;
|
||||
|
||||
uint16_t *a = CONVERT_TO_SHORTPTR(a8);
|
||||
uint16_t *b = CONVERT_TO_SHORTPTR(b8);
|
||||
*sum = 0;
|
||||
*sse = 0;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
for (j = 0; j < w; j++) {
|
||||
const int diff = a[j] - b[j];
|
||||
*sum += diff;
|
||||
*sse += diff * diff;
|
||||
}
|
||||
a += a_stride;
|
||||
b += b_stride;
|
||||
}
|
||||
}
|
||||
|
||||
static void aq_highbd_8_variance(const uint8_t *a8, int a_stride,
|
||||
const uint8_t *b8, int b_stride, int w, int h,
|
||||
unsigned int *sse, int *sum) {
|
||||
uint64_t sse_long = 0;
|
||||
uint64_t sum_long = 0;
|
||||
aq_highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, &sum_long);
|
||||
*sse = (unsigned int)sse_long;
|
||||
*sum = (int)sum_long;
|
||||
}
|
||||
|
||||
static unsigned int block_variance(const AV1_COMP *const cpi, MACROBLOCK *x,
|
||||
BLOCK_SIZE bs) {
|
||||
MACROBLOCKD *xd = &x->e_mbd;
|
||||
unsigned int var, sse;
|
||||
double var = 0;
|
||||
unsigned int sse;
|
||||
int i, j;
|
||||
|
||||
int right_overflow =
|
||||
(xd->mb_to_right_edge < 0) ? ((-xd->mb_to_right_edge) >> 3) : 0;
|
||||
int bottom_overflow =
|
||||
(xd->mb_to_bottom_edge < 0) ? ((-xd->mb_to_bottom_edge) >> 3) : 0;
|
||||
|
||||
if (right_overflow || bottom_overflow) {
|
||||
const int bw = MI_SIZE * mi_size_wide[bs] - right_overflow;
|
||||
const int bh = MI_SIZE * mi_size_high[bs] - bottom_overflow;
|
||||
int avg;
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||
aq_highbd_8_variance(x->plane[0].src.buf, x->plane[0].src.stride,
|
||||
CONVERT_TO_BYTEPTR(av1_highbd_all_zeros), 0, bw, bh,
|
||||
&sse, &avg);
|
||||
sse >>= 2 * (xd->bd - 8);
|
||||
avg >>= (xd->bd - 8);
|
||||
} else {
|
||||
aq_variance(x->plane[0].src.buf, x->plane[0].src.stride, av1_all_zeros, 0,
|
||||
bw, bh, &sse, &avg);
|
||||
}
|
||||
var = sse - (unsigned int)(((int64_t)avg * avg) / (bw * bh));
|
||||
return (unsigned int)((uint64_t)var * 256) / (bw * bh);
|
||||
} else {
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||
var =
|
||||
cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride,
|
||||
CONVERT_TO_BYTEPTR(av1_highbd_all_zeros), 0, &sse);
|
||||
} else {
|
||||
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride,
|
||||
av1_all_zeros, 0, &sse);
|
||||
}
|
||||
return (unsigned int)((uint64_t)var * 256) >> num_pels_log2_lookup[bs];
|
||||
}
|
||||
}
|
||||
const int bw = MI_SIZE * mi_size_wide[bs] - right_overflow;
|
||||
const int bh = MI_SIZE * mi_size_high[bs] - bottom_overflow;
|
||||
|
||||
double av1_log_block_var(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) {
|
||||
unsigned int var = block_variance(cpi, x, bs);
|
||||
aom_clear_system_state();
|
||||
return log(var + 1.0);
|
||||
|
||||
for (i = 0; i < bh; i += 4) {
|
||||
for (j = 0; j < bw; j += 4) {
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||
var +=
|
||||
log(1.0 + cpi->fn_ptr[BLOCK_4X4].vf(
|
||||
x->plane[0].src.buf + i * x->plane[0].src.stride + j,
|
||||
x->plane[0].src.stride,
|
||||
CONVERT_TO_BYTEPTR(av1_highbd_all_zeros), 0, &sse) /
|
||||
16);
|
||||
} else {
|
||||
var +=
|
||||
log(1.0 + cpi->fn_ptr[BLOCK_4X4].vf(
|
||||
x->plane[0].src.buf + i * x->plane[0].src.stride + j,
|
||||
x->plane[0].src.stride, av1_all_zeros, 0, &sse) /
|
||||
16);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Use average of 4x4 log variance. The range for 8 bit 0 - 9.704121561.
|
||||
var /= (bw / 4 * bh / 4);
|
||||
if (var > 7) var = 7;
|
||||
|
||||
aom_clear_system_state();
|
||||
return (int)(var);
|
||||
}
|
||||
|
||||
#define DEFAULT_E_MIDPOINT 10.0
|
||||
int av1_block_energy(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) {
|
||||
double energy;
|
||||
double energy_midpoint;
|
||||
aom_clear_system_state();
|
||||
energy_midpoint =
|
||||
(cpi->oxcf.pass == 2) ? cpi->twopass.mb_av_energy : DEFAULT_E_MIDPOINT;
|
||||
energy = av1_log_block_var(cpi, x, bs) - energy_midpoint;
|
||||
return clamp((int)round(energy), ENERGY_MIN, ENERGY_MAX);
|
||||
}
|
||||
|
||||
unsigned int haar_ac_energy(MACROBLOCK *x, BLOCK_SIZE bs) {
|
||||
MACROBLOCKD *xd = &x->e_mbd;
|
||||
|
|
@ -231,17 +182,21 @@ int av1_block_wavelet_energy_level(const AV1_COMP *cpi, MACROBLOCK *x,
|
|||
|
||||
int av1_compute_deltaq_from_energy_level(const AV1_COMP *const cpi,
|
||||
int block_var_level) {
|
||||
ENERGY_IN_BOUNDS(block_var_level);
|
||||
|
||||
const int rate_level = SEGMENT_ID(block_var_level);
|
||||
int rate_level;
|
||||
const AV1_COMMON *const cm = &cpi->common;
|
||||
|
||||
if (DELTAQ_MODULATION == 1) {
|
||||
ENERGY_IN_BOUNDS(block_var_level);
|
||||
rate_level = SEGMENT_ID(block_var_level);
|
||||
} else {
|
||||
rate_level = block_var_level;
|
||||
}
|
||||
int qindex_delta = av1_compute_qdelta_by_rate(
|
||||
&cpi->rc, cm->frame_type, cm->base_qindex, rate_ratio[rate_level],
|
||||
&cpi->rc, cm->frame_type, cm->base_qindex, deltaq_rate_ratio[rate_level],
|
||||
cm->seq_params.bit_depth);
|
||||
|
||||
if ((cm->base_qindex != 0) && ((cm->base_qindex + qindex_delta) == 0)) {
|
||||
qindex_delta = -cm->base_qindex + 1;
|
||||
}
|
||||
|
||||
return qindex_delta;
|
||||
}
|
||||
|
|
|
|||
10
third_party/aom/av1/encoder/aq_variance.h
vendored
10
third_party/aom/av1/encoder/aq_variance.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_AQ_VARIANCE_H_
|
||||
#define AV1_ENCODER_AQ_VARIANCE_H_
|
||||
#ifndef AOM_AV1_ENCODER_AQ_VARIANCE_H_
|
||||
#define AOM_AV1_ENCODER_AQ_VARIANCE_H_
|
||||
|
||||
#include "av1/encoder/encoder.h"
|
||||
|
||||
|
|
@ -18,11 +18,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
unsigned int av1_vaq_segment_id(int energy);
|
||||
void av1_vaq_frame_setup(AV1_COMP *cpi);
|
||||
|
||||
int av1_block_energy(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs);
|
||||
double av1_log_block_var(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs);
|
||||
int av1_log_block_var(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs);
|
||||
int av1_compute_deltaq_from_energy_level(const AV1_COMP *const cpi,
|
||||
int block_var_level);
|
||||
int av1_block_wavelet_energy_level(const AV1_COMP *cpi, MACROBLOCK *x,
|
||||
|
|
@ -32,4 +30,4 @@ int av1_block_wavelet_energy_level(const AV1_COMP *cpi, MACROBLOCK *x,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_AQ_VARIANCE_H_
|
||||
#endif // AOM_AV1_ENCODER_AQ_VARIANCE_H_
|
||||
|
|
|
|||
147
third_party/aom/av1/encoder/av1_fwd_txfm1d.c
vendored
147
third_party/aom/av1/encoder/av1_fwd_txfm1d.c
vendored
|
|
@ -11,24 +11,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include "av1/encoder/av1_fwd_txfm1d.h"
|
||||
|
||||
#if CONFIG_COEFFICIENT_RANGE_CHECKING
|
||||
void range_check_func(int32_t stage, const int32_t *input, const int32_t *buf,
|
||||
int32_t size, int8_t bit);
|
||||
|
||||
#define range_check(stage, input, buf, size, bit) \
|
||||
range_check_func(stage, input, buf, size, bit)
|
||||
#else // CONFIG_COEFFICIENT_RANGE_CHECKING
|
||||
|
||||
#define range_check(stage, input, buf, size, bit) \
|
||||
{ \
|
||||
(void)stage; \
|
||||
(void)input; \
|
||||
(void)buf; \
|
||||
(void)size; \
|
||||
(void)bit; \
|
||||
}
|
||||
#endif // CONFIG_COEFFICIENT_RANGE_CHECKING
|
||||
#include "av1/common/av1_txfm.h"
|
||||
|
||||
void av1_fdct4_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
const int8_t *stage_range) {
|
||||
|
|
@ -40,7 +23,7 @@ void av1_fdct4_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
int32_t step[4];
|
||||
|
||||
// stage 0;
|
||||
range_check(stage, input, input, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, input, size, stage_range[stage]);
|
||||
|
||||
// stage 1;
|
||||
stage++;
|
||||
|
|
@ -49,7 +32,7 @@ void av1_fdct4_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[1] = input[1] + input[2];
|
||||
bf1[2] = -input[2] + input[1];
|
||||
bf1[3] = -input[3] + input[0];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 2
|
||||
stage++;
|
||||
|
|
@ -60,7 +43,7 @@ void av1_fdct4_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[1] = half_btf(-cospi[32], bf0[1], cospi[32], bf0[0], cos_bit);
|
||||
bf1[2] = half_btf(cospi[48], bf0[2], cospi[16], bf0[3], cos_bit);
|
||||
bf1[3] = half_btf(cospi[48], bf0[3], -cospi[16], bf0[2], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 3
|
||||
stage++;
|
||||
|
|
@ -70,7 +53,7 @@ void av1_fdct4_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[1] = bf0[2];
|
||||
bf1[2] = bf0[1];
|
||||
bf1[3] = bf0[3];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
}
|
||||
|
||||
void av1_fdct8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
|
|
@ -83,7 +66,7 @@ void av1_fdct8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
int32_t step[8];
|
||||
|
||||
// stage 0;
|
||||
range_check(stage, input, input, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, input, size, stage_range[stage]);
|
||||
|
||||
// stage 1;
|
||||
stage++;
|
||||
|
|
@ -96,7 +79,7 @@ void av1_fdct8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = -input[5] + input[2];
|
||||
bf1[6] = -input[6] + input[1];
|
||||
bf1[7] = -input[7] + input[0];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 2
|
||||
stage++;
|
||||
|
|
@ -111,7 +94,7 @@ void av1_fdct8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = half_btf(-cospi[32], bf0[5], cospi[32], bf0[6], cos_bit);
|
||||
bf1[6] = half_btf(cospi[32], bf0[6], cospi[32], bf0[5], cos_bit);
|
||||
bf1[7] = bf0[7];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 3
|
||||
stage++;
|
||||
|
|
@ -126,7 +109,7 @@ void av1_fdct8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = -bf0[5] + bf0[4];
|
||||
bf1[6] = -bf0[6] + bf0[7];
|
||||
bf1[7] = bf0[7] + bf0[6];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 4
|
||||
stage++;
|
||||
|
|
@ -141,7 +124,7 @@ void av1_fdct8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = half_btf(cospi[24], bf0[5], cospi[40], bf0[6], cos_bit);
|
||||
bf1[6] = half_btf(cospi[24], bf0[6], -cospi[40], bf0[5], cos_bit);
|
||||
bf1[7] = half_btf(cospi[56], bf0[7], -cospi[8], bf0[4], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 5
|
||||
stage++;
|
||||
|
|
@ -155,7 +138,7 @@ void av1_fdct8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = bf0[5];
|
||||
bf1[6] = bf0[3];
|
||||
bf1[7] = bf0[7];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
}
|
||||
|
||||
void av1_fdct16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
|
|
@ -168,7 +151,7 @@ void av1_fdct16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
int32_t step[16];
|
||||
|
||||
// stage 0;
|
||||
range_check(stage, input, input, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, input, size, stage_range[stage]);
|
||||
|
||||
// stage 1;
|
||||
stage++;
|
||||
|
|
@ -189,7 +172,7 @@ void av1_fdct16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = -input[13] + input[2];
|
||||
bf1[14] = -input[14] + input[1];
|
||||
bf1[15] = -input[15] + input[0];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 2
|
||||
stage++;
|
||||
|
|
@ -212,7 +195,7 @@ void av1_fdct16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = half_btf(cospi[32], bf0[13], cospi[32], bf0[10], cos_bit);
|
||||
bf1[14] = bf0[14];
|
||||
bf1[15] = bf0[15];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 3
|
||||
stage++;
|
||||
|
|
@ -235,7 +218,7 @@ void av1_fdct16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = -bf0[13] + bf0[14];
|
||||
bf1[14] = bf0[14] + bf0[13];
|
||||
bf1[15] = bf0[15] + bf0[12];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 4
|
||||
stage++;
|
||||
|
|
@ -258,7 +241,7 @@ void av1_fdct16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = half_btf(cospi[48], bf0[13], -cospi[16], bf0[10], cos_bit);
|
||||
bf1[14] = half_btf(cospi[16], bf0[14], cospi[48], bf0[9], cos_bit);
|
||||
bf1[15] = bf0[15];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 5
|
||||
stage++;
|
||||
|
|
@ -281,7 +264,7 @@ void av1_fdct16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = -bf0[13] + bf0[12];
|
||||
bf1[14] = -bf0[14] + bf0[15];
|
||||
bf1[15] = bf0[15] + bf0[14];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 6
|
||||
stage++;
|
||||
|
|
@ -304,7 +287,7 @@ void av1_fdct16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = half_btf(cospi[44], bf0[13], -cospi[20], bf0[10], cos_bit);
|
||||
bf1[14] = half_btf(cospi[28], bf0[14], -cospi[36], bf0[9], cos_bit);
|
||||
bf1[15] = half_btf(cospi[60], bf0[15], -cospi[4], bf0[8], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 7
|
||||
stage++;
|
||||
|
|
@ -326,7 +309,7 @@ void av1_fdct16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = bf0[11];
|
||||
bf1[14] = bf0[7];
|
||||
bf1[15] = bf0[15];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
}
|
||||
|
||||
void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
|
|
@ -339,7 +322,7 @@ void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
int32_t step[32];
|
||||
|
||||
// stage 0;
|
||||
range_check(stage, input, input, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, input, size, stage_range[stage]);
|
||||
|
||||
// stage 1;
|
||||
stage++;
|
||||
|
|
@ -376,7 +359,7 @@ void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[29] = -input[29] + input[2];
|
||||
bf1[30] = -input[30] + input[1];
|
||||
bf1[31] = -input[31] + input[0];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 2
|
||||
stage++;
|
||||
|
|
@ -415,7 +398,7 @@ void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[29] = bf0[29];
|
||||
bf1[30] = bf0[30];
|
||||
bf1[31] = bf0[31];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 3
|
||||
stage++;
|
||||
|
|
@ -454,7 +437,7 @@ void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[29] = bf0[29] + bf0[26];
|
||||
bf1[30] = bf0[30] + bf0[25];
|
||||
bf1[31] = bf0[31] + bf0[24];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 4
|
||||
stage++;
|
||||
|
|
@ -493,7 +476,7 @@ void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[29] = half_btf(cospi[16], bf0[29], cospi[48], bf0[18], cos_bit);
|
||||
bf1[30] = bf0[30];
|
||||
bf1[31] = bf0[31];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 5
|
||||
stage++;
|
||||
|
|
@ -532,7 +515,7 @@ void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[29] = -bf0[29] + bf0[30];
|
||||
bf1[30] = bf0[30] + bf0[29];
|
||||
bf1[31] = bf0[31] + bf0[28];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 6
|
||||
stage++;
|
||||
|
|
@ -571,7 +554,7 @@ void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[29] = half_btf(cospi[56], bf0[29], -cospi[8], bf0[18], cos_bit);
|
||||
bf1[30] = half_btf(cospi[8], bf0[30], cospi[56], bf0[17], cos_bit);
|
||||
bf1[31] = bf0[31];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 7
|
||||
stage++;
|
||||
|
|
@ -610,7 +593,7 @@ void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[29] = -bf0[29] + bf0[28];
|
||||
bf1[30] = -bf0[30] + bf0[31];
|
||||
bf1[31] = bf0[31] + bf0[30];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 8
|
||||
stage++;
|
||||
|
|
@ -649,7 +632,7 @@ void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[29] = half_btf(cospi[46], bf0[29], -cospi[18], bf0[18], cos_bit);
|
||||
bf1[30] = half_btf(cospi[30], bf0[30], -cospi[34], bf0[17], cos_bit);
|
||||
bf1[31] = half_btf(cospi[62], bf0[31], -cospi[2], bf0[16], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 9
|
||||
stage++;
|
||||
|
|
@ -687,7 +670,7 @@ void av1_fdct32_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[29] = bf0[23];
|
||||
bf1[30] = bf0[15];
|
||||
bf1[31] = bf0[31];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
}
|
||||
|
||||
void av1_fadst4_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
|
|
@ -698,7 +681,7 @@ void av1_fadst4_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
int32_t s0, s1, s2, s3, s4, s5, s6, s7;
|
||||
|
||||
// stage 0
|
||||
range_check(0, input, input, 4, stage_range[0]);
|
||||
av1_range_check_buf(0, input, input, 4, stage_range[0]);
|
||||
x0 = input[0];
|
||||
x1 = input[1];
|
||||
x2 = input[2];
|
||||
|
|
@ -746,7 +729,7 @@ void av1_fadst4_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
output[1] = round_shift(s1, bit);
|
||||
output[2] = round_shift(s2, bit);
|
||||
output[3] = round_shift(s3, bit);
|
||||
range_check(6, input, output, 4, stage_range[6]);
|
||||
av1_range_check_buf(6, input, output, 4, stage_range[6]);
|
||||
}
|
||||
|
||||
void av1_fadst8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
|
|
@ -759,7 +742,7 @@ void av1_fadst8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
int32_t step[8];
|
||||
|
||||
// stage 0;
|
||||
range_check(stage, input, input, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, input, size, stage_range[stage]);
|
||||
|
||||
// stage 1;
|
||||
stage++;
|
||||
|
|
@ -773,7 +756,7 @@ void av1_fadst8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = input[6];
|
||||
bf1[6] = input[2];
|
||||
bf1[7] = -input[5];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 2
|
||||
stage++;
|
||||
|
|
@ -788,7 +771,7 @@ void av1_fadst8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = bf0[5];
|
||||
bf1[6] = half_btf(cospi[32], bf0[6], cospi[32], bf0[7], cos_bit);
|
||||
bf1[7] = half_btf(cospi[32], bf0[6], -cospi[32], bf0[7], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 3
|
||||
stage++;
|
||||
|
|
@ -802,7 +785,7 @@ void av1_fadst8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = bf0[5] + bf0[7];
|
||||
bf1[6] = bf0[4] - bf0[6];
|
||||
bf1[7] = bf0[5] - bf0[7];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 4
|
||||
stage++;
|
||||
|
|
@ -817,7 +800,7 @@ void av1_fadst8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = half_btf(cospi[48], bf0[4], -cospi[16], bf0[5], cos_bit);
|
||||
bf1[6] = half_btf(-cospi[48], bf0[6], cospi[16], bf0[7], cos_bit);
|
||||
bf1[7] = half_btf(cospi[16], bf0[6], cospi[48], bf0[7], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 5
|
||||
stage++;
|
||||
|
|
@ -831,7 +814,7 @@ void av1_fadst8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = bf0[1] - bf0[5];
|
||||
bf1[6] = bf0[2] - bf0[6];
|
||||
bf1[7] = bf0[3] - bf0[7];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 6
|
||||
stage++;
|
||||
|
|
@ -846,7 +829,7 @@ void av1_fadst8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = half_btf(cospi[28], bf0[4], -cospi[36], bf0[5], cos_bit);
|
||||
bf1[6] = half_btf(cospi[52], bf0[6], cospi[12], bf0[7], cos_bit);
|
||||
bf1[7] = half_btf(cospi[12], bf0[6], -cospi[52], bf0[7], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 7
|
||||
stage++;
|
||||
|
|
@ -860,7 +843,7 @@ void av1_fadst8_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[5] = bf0[2];
|
||||
bf1[6] = bf0[7];
|
||||
bf1[7] = bf0[0];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
}
|
||||
|
||||
void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
|
|
@ -873,7 +856,7 @@ void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
int32_t step[16];
|
||||
|
||||
// stage 0;
|
||||
range_check(stage, input, input, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, input, size, stage_range[stage]);
|
||||
|
||||
// stage 1;
|
||||
stage++;
|
||||
|
|
@ -895,7 +878,7 @@ void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = -input[13];
|
||||
bf1[14] = -input[5];
|
||||
bf1[15] = input[10];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 2
|
||||
stage++;
|
||||
|
|
@ -918,7 +901,7 @@ void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = bf0[13];
|
||||
bf1[14] = half_btf(cospi[32], bf0[14], cospi[32], bf0[15], cos_bit);
|
||||
bf1[15] = half_btf(cospi[32], bf0[14], -cospi[32], bf0[15], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 3
|
||||
stage++;
|
||||
|
|
@ -940,7 +923,7 @@ void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = bf0[13] + bf0[15];
|
||||
bf1[14] = bf0[12] - bf0[14];
|
||||
bf1[15] = bf0[13] - bf0[15];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 4
|
||||
stage++;
|
||||
|
|
@ -963,7 +946,7 @@ void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = half_btf(cospi[48], bf0[12], -cospi[16], bf0[13], cos_bit);
|
||||
bf1[14] = half_btf(-cospi[48], bf0[14], cospi[16], bf0[15], cos_bit);
|
||||
bf1[15] = half_btf(cospi[16], bf0[14], cospi[48], bf0[15], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 5
|
||||
stage++;
|
||||
|
|
@ -985,7 +968,7 @@ void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = bf0[9] - bf0[13];
|
||||
bf1[14] = bf0[10] - bf0[14];
|
||||
bf1[15] = bf0[11] - bf0[15];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 6
|
||||
stage++;
|
||||
|
|
@ -1008,7 +991,7 @@ void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = half_btf(cospi[8], bf0[12], cospi[56], bf0[13], cos_bit);
|
||||
bf1[14] = half_btf(-cospi[24], bf0[14], cospi[40], bf0[15], cos_bit);
|
||||
bf1[15] = half_btf(cospi[40], bf0[14], cospi[24], bf0[15], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 7
|
||||
stage++;
|
||||
|
|
@ -1030,7 +1013,7 @@ void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = bf0[5] - bf0[13];
|
||||
bf1[14] = bf0[6] - bf0[14];
|
||||
bf1[15] = bf0[7] - bf0[15];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 8
|
||||
stage++;
|
||||
|
|
@ -1053,7 +1036,7 @@ void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = half_btf(cospi[14], bf0[12], -cospi[50], bf0[13], cos_bit);
|
||||
bf1[14] = half_btf(cospi[58], bf0[14], cospi[6], bf0[15], cos_bit);
|
||||
bf1[15] = half_btf(cospi[6], bf0[14], -cospi[58], bf0[15], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 9
|
||||
stage++;
|
||||
|
|
@ -1075,7 +1058,7 @@ void av1_fadst16_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[13] = bf0[2];
|
||||
bf1[14] = bf0[15];
|
||||
bf1[15] = bf0[0];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
}
|
||||
|
||||
void av1_fidentity4_c(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
|
|
@ -1084,14 +1067,14 @@ void av1_fidentity4_c(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
for (int i = 0; i < 4; ++i)
|
||||
output[i] = round_shift((int64_t)input[i] * NewSqrt2, NewSqrt2Bits);
|
||||
assert(stage_range[0] + NewSqrt2Bits <= 32);
|
||||
range_check(0, input, output, 4, stage_range[0]);
|
||||
av1_range_check_buf(0, input, output, 4, stage_range[0]);
|
||||
}
|
||||
|
||||
void av1_fidentity8_c(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
const int8_t *stage_range) {
|
||||
(void)cos_bit;
|
||||
for (int i = 0; i < 8; ++i) output[i] = input[i] * 2;
|
||||
range_check(0, input, output, 8, stage_range[0]);
|
||||
av1_range_check_buf(0, input, output, 8, stage_range[0]);
|
||||
}
|
||||
|
||||
void av1_fidentity16_c(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
|
|
@ -1100,14 +1083,14 @@ void av1_fidentity16_c(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
for (int i = 0; i < 16; ++i)
|
||||
output[i] = round_shift((int64_t)input[i] * 2 * NewSqrt2, NewSqrt2Bits);
|
||||
assert(stage_range[0] + NewSqrt2Bits <= 32);
|
||||
range_check(0, input, output, 16, stage_range[0]);
|
||||
av1_range_check_buf(0, input, output, 16, stage_range[0]);
|
||||
}
|
||||
|
||||
void av1_fidentity32_c(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
const int8_t *stage_range) {
|
||||
(void)cos_bit;
|
||||
for (int i = 0; i < 32; ++i) output[i] = input[i] * 4;
|
||||
range_check(0, input, output, 32, stage_range[0]);
|
||||
av1_range_check_buf(0, input, output, 32, stage_range[0]);
|
||||
}
|
||||
|
||||
void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
||||
|
|
@ -1120,7 +1103,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
int32_t step[64];
|
||||
|
||||
// stage 0;
|
||||
range_check(stage, input, input, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, input, size, stage_range[stage]);
|
||||
|
||||
// stage 1;
|
||||
stage++;
|
||||
|
|
@ -1189,7 +1172,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = -input[61] + input[2];
|
||||
bf1[62] = -input[62] + input[1];
|
||||
bf1[63] = -input[63] + input[0];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 2
|
||||
stage++;
|
||||
|
|
@ -1260,7 +1243,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = bf0[61];
|
||||
bf1[62] = bf0[62];
|
||||
bf1[63] = bf0[63];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 3
|
||||
stage++;
|
||||
|
|
@ -1331,7 +1314,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = bf0[61] + bf0[50];
|
||||
bf1[62] = bf0[62] + bf0[49];
|
||||
bf1[63] = bf0[63] + bf0[48];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 4
|
||||
stage++;
|
||||
|
|
@ -1402,7 +1385,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = bf0[61];
|
||||
bf1[62] = bf0[62];
|
||||
bf1[63] = bf0[63];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 5
|
||||
stage++;
|
||||
|
|
@ -1473,7 +1456,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = bf0[61] + bf0[58];
|
||||
bf1[62] = bf0[62] + bf0[57];
|
||||
bf1[63] = bf0[63] + bf0[56];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 6
|
||||
stage++;
|
||||
|
|
@ -1544,7 +1527,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = half_btf(cospi[8], bf0[61], cospi[56], bf0[34], cos_bit);
|
||||
bf1[62] = bf0[62];
|
||||
bf1[63] = bf0[63];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 7
|
||||
stage++;
|
||||
|
|
@ -1615,7 +1598,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = -bf0[61] + bf0[62];
|
||||
bf1[62] = bf0[62] + bf0[61];
|
||||
bf1[63] = bf0[63] + bf0[60];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 8
|
||||
stage++;
|
||||
|
|
@ -1686,7 +1669,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = half_btf(cospi[60], bf0[61], -cospi[4], bf0[34], cos_bit);
|
||||
bf1[62] = half_btf(cospi[4], bf0[62], cospi[60], bf0[33], cos_bit);
|
||||
bf1[63] = bf0[63];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 9
|
||||
stage++;
|
||||
|
|
@ -1757,7 +1740,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = -bf0[61] + bf0[60];
|
||||
bf1[62] = -bf0[62] + bf0[63];
|
||||
bf1[63] = bf0[63] + bf0[62];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 10
|
||||
stage++;
|
||||
|
|
@ -1828,7 +1811,7 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = half_btf(cospi[47], bf0[61], -cospi[17], bf0[34], cos_bit);
|
||||
bf1[62] = half_btf(cospi[31], bf0[62], -cospi[33], bf0[33], cos_bit);
|
||||
bf1[63] = half_btf(cospi[63], bf0[63], -cospi[1], bf0[32], cos_bit);
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
|
||||
// stage 11
|
||||
stage++;
|
||||
|
|
@ -1898,5 +1881,5 @@ void av1_fdct64_new(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
bf1[61] = bf0[47];
|
||||
bf1[62] = bf0[31];
|
||||
bf1[63] = bf0[63];
|
||||
range_check(stage, input, bf1, size, stage_range[stage]);
|
||||
av1_range_check_buf(stage, input, bf1, size, stage_range[stage]);
|
||||
}
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/av1_fwd_txfm1d.h
vendored
6
third_party/aom/av1/encoder/av1_fwd_txfm1d.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_FWD_TXFM1D_H_
|
||||
#define AV1_FWD_TXFM1D_H_
|
||||
#ifndef AOM_AV1_ENCODER_AV1_FWD_TXFM1D_H_
|
||||
#define AOM_AV1_ENCODER_AV1_FWD_TXFM1D_H_
|
||||
|
||||
#include "av1/common/av1_txfm.h"
|
||||
|
||||
|
|
@ -46,4 +46,4 @@ void av1_fidentity32_c(const int32_t *input, int32_t *output, int8_t cos_bit,
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif // AV1_FWD_TXFM1D_H_
|
||||
#endif // AOM_AV1_ENCODER_AV1_FWD_TXFM1D_H_
|
||||
|
|
|
|||
|
|
@ -9,11 +9,11 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_FWD_TXFM2D_CFG_H_
|
||||
#define AV1_FWD_TXFM2D_CFG_H_
|
||||
#ifndef AOM_AV1_ENCODER_AV1_FWD_TXFM1D_CFG_H_
|
||||
#define AOM_AV1_ENCODER_AV1_FWD_TXFM1D_CFG_H_
|
||||
#include "av1/common/enums.h"
|
||||
#include "av1/encoder/av1_fwd_txfm1d.h"
|
||||
extern const int8_t *fwd_txfm_shift_ls[TX_SIZES_ALL];
|
||||
extern const int8_t fwd_cos_bit_col[5][5];
|
||||
extern const int8_t fwd_cos_bit_row[5][5];
|
||||
#endif // AV1_FWD_TXFM2D_CFG_H_
|
||||
#endif // AOM_AV1_ENCODER_AV1_FWD_TXFM1D_CFG_H_
|
||||
|
|
|
|||
68
third_party/aom/av1/encoder/av1_quantize.c
vendored
68
third_party/aom/av1/encoder/av1_quantize.c
vendored
|
|
@ -273,35 +273,32 @@ void av1_quantize_b_facade(const tran_low_t *coeff_ptr, intptr_t n_coeffs,
|
|||
const MACROBLOCK_PLANE *p, tran_low_t *qcoeff_ptr,
|
||||
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
|
||||
const SCAN_ORDER *sc, const QUANT_PARAM *qparam) {
|
||||
// obsolete skip_block
|
||||
const int skip_block = 0;
|
||||
const qm_val_t *qm_ptr = qparam->qmatrix;
|
||||
const qm_val_t *iqm_ptr = qparam->iqmatrix;
|
||||
if (qm_ptr != NULL && iqm_ptr != NULL) {
|
||||
quantize_b_helper_c(coeff_ptr, n_coeffs, skip_block, p->zbin_QTX,
|
||||
p->round_QTX, p->quant_QTX, p->quant_shift_QTX,
|
||||
qcoeff_ptr, dqcoeff_ptr, p->dequant_QTX, eob_ptr,
|
||||
sc->scan, sc->iscan, qm_ptr, iqm_ptr,
|
||||
qparam->log_scale);
|
||||
quantize_b_helper_c(coeff_ptr, n_coeffs, p->zbin_QTX, p->round_QTX,
|
||||
p->quant_QTX, p->quant_shift_QTX, qcoeff_ptr,
|
||||
dqcoeff_ptr, p->dequant_QTX, eob_ptr, sc->scan,
|
||||
sc->iscan, qm_ptr, iqm_ptr, qparam->log_scale);
|
||||
} else {
|
||||
switch (qparam->log_scale) {
|
||||
case 0:
|
||||
aom_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin_QTX,
|
||||
p->round_QTX, p->quant_QTX, p->quant_shift_QTX,
|
||||
qcoeff_ptr, dqcoeff_ptr, p->dequant_QTX, eob_ptr,
|
||||
sc->scan, sc->iscan);
|
||||
aom_quantize_b(coeff_ptr, n_coeffs, p->zbin_QTX, p->round_QTX,
|
||||
p->quant_QTX, p->quant_shift_QTX, qcoeff_ptr,
|
||||
dqcoeff_ptr, p->dequant_QTX, eob_ptr, sc->scan,
|
||||
sc->iscan);
|
||||
break;
|
||||
case 1:
|
||||
aom_quantize_b_32x32(coeff_ptr, n_coeffs, skip_block, p->zbin_QTX,
|
||||
p->round_QTX, p->quant_QTX, p->quant_shift_QTX,
|
||||
qcoeff_ptr, dqcoeff_ptr, p->dequant_QTX, eob_ptr,
|
||||
sc->scan, sc->iscan);
|
||||
aom_quantize_b_32x32(coeff_ptr, n_coeffs, p->zbin_QTX, p->round_QTX,
|
||||
p->quant_QTX, p->quant_shift_QTX, qcoeff_ptr,
|
||||
dqcoeff_ptr, p->dequant_QTX, eob_ptr, sc->scan,
|
||||
sc->iscan);
|
||||
break;
|
||||
case 2:
|
||||
aom_quantize_b_64x64(coeff_ptr, n_coeffs, skip_block, p->zbin_QTX,
|
||||
p->round_QTX, p->quant_QTX, p->quant_shift_QTX,
|
||||
qcoeff_ptr, dqcoeff_ptr, p->dequant_QTX, eob_ptr,
|
||||
sc->scan, sc->iscan);
|
||||
aom_quantize_b_64x64(coeff_ptr, n_coeffs, p->zbin_QTX, p->round_QTX,
|
||||
p->quant_QTX, p->quant_shift_QTX, qcoeff_ptr,
|
||||
dqcoeff_ptr, p->dequant_QTX, eob_ptr, sc->scan,
|
||||
sc->iscan);
|
||||
break;
|
||||
default: assert(0);
|
||||
}
|
||||
|
|
@ -392,28 +389,25 @@ void av1_highbd_quantize_b_facade(const tran_low_t *coeff_ptr,
|
|||
tran_low_t *dqcoeff_ptr, uint16_t *eob_ptr,
|
||||
const SCAN_ORDER *sc,
|
||||
const QUANT_PARAM *qparam) {
|
||||
// obsolete skip_block
|
||||
const int skip_block = 0;
|
||||
const qm_val_t *qm_ptr = qparam->qmatrix;
|
||||
const qm_val_t *iqm_ptr = qparam->iqmatrix;
|
||||
if (qm_ptr != NULL && iqm_ptr != NULL) {
|
||||
highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, skip_block, p->zbin_QTX,
|
||||
p->round_QTX, p->quant_QTX, p->quant_shift_QTX,
|
||||
qcoeff_ptr, dqcoeff_ptr, p->dequant_QTX, eob_ptr,
|
||||
sc->scan, sc->iscan, qm_ptr, iqm_ptr,
|
||||
qparam->log_scale);
|
||||
highbd_quantize_b_helper_c(coeff_ptr, n_coeffs, p->zbin_QTX, p->round_QTX,
|
||||
p->quant_QTX, p->quant_shift_QTX, qcoeff_ptr,
|
||||
dqcoeff_ptr, p->dequant_QTX, eob_ptr, sc->scan,
|
||||
sc->iscan, qm_ptr, iqm_ptr, qparam->log_scale);
|
||||
} else {
|
||||
switch (qparam->log_scale) {
|
||||
case 0:
|
||||
if (LIKELY(n_coeffs >= 8)) {
|
||||
aom_highbd_quantize_b(coeff_ptr, n_coeffs, skip_block, p->zbin_QTX,
|
||||
p->round_QTX, p->quant_QTX, p->quant_shift_QTX,
|
||||
qcoeff_ptr, dqcoeff_ptr, p->dequant_QTX,
|
||||
eob_ptr, sc->scan, sc->iscan);
|
||||
aom_highbd_quantize_b(coeff_ptr, n_coeffs, p->zbin_QTX, p->round_QTX,
|
||||
p->quant_QTX, p->quant_shift_QTX, qcoeff_ptr,
|
||||
dqcoeff_ptr, p->dequant_QTX, eob_ptr, sc->scan,
|
||||
sc->iscan);
|
||||
} else {
|
||||
// TODO(luoyi): Need SIMD (e.g. sse2) for smaller block size
|
||||
// quantization
|
||||
aom_highbd_quantize_b_c(coeff_ptr, n_coeffs, skip_block, p->zbin_QTX,
|
||||
aom_highbd_quantize_b_c(coeff_ptr, n_coeffs, p->zbin_QTX,
|
||||
p->round_QTX, p->quant_QTX,
|
||||
p->quant_shift_QTX, qcoeff_ptr, dqcoeff_ptr,
|
||||
p->dequant_QTX, eob_ptr, sc->scan, sc->iscan);
|
||||
|
|
@ -421,15 +415,15 @@ void av1_highbd_quantize_b_facade(const tran_low_t *coeff_ptr,
|
|||
break;
|
||||
case 1:
|
||||
aom_highbd_quantize_b_32x32(
|
||||
coeff_ptr, n_coeffs, skip_block, p->zbin_QTX, p->round_QTX,
|
||||
p->quant_QTX, p->quant_shift_QTX, qcoeff_ptr, dqcoeff_ptr,
|
||||
p->dequant_QTX, eob_ptr, sc->scan, sc->iscan);
|
||||
coeff_ptr, n_coeffs, p->zbin_QTX, p->round_QTX, p->quant_QTX,
|
||||
p->quant_shift_QTX, qcoeff_ptr, dqcoeff_ptr, p->dequant_QTX,
|
||||
eob_ptr, sc->scan, sc->iscan);
|
||||
break;
|
||||
case 2:
|
||||
aom_highbd_quantize_b_64x64(
|
||||
coeff_ptr, n_coeffs, skip_block, p->zbin_QTX, p->round_QTX,
|
||||
p->quant_QTX, p->quant_shift_QTX, qcoeff_ptr, dqcoeff_ptr,
|
||||
p->dequant_QTX, eob_ptr, sc->scan, sc->iscan);
|
||||
coeff_ptr, n_coeffs, p->zbin_QTX, p->round_QTX, p->quant_QTX,
|
||||
p->quant_shift_QTX, qcoeff_ptr, dqcoeff_ptr, p->dequant_QTX,
|
||||
eob_ptr, sc->scan, sc->iscan);
|
||||
break;
|
||||
default: assert(0);
|
||||
}
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/av1_quantize.h
vendored
6
third_party/aom/av1/encoder/av1_quantize.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_QUANTIZE_H_
|
||||
#define AV1_ENCODER_QUANTIZE_H_
|
||||
#ifndef AOM_AV1_ENCODER_AV1_QUANTIZE_H_
|
||||
#define AOM_AV1_ENCODER_AV1_QUANTIZE_H_
|
||||
|
||||
#include "config/aom_config.h"
|
||||
|
||||
|
|
@ -145,4 +145,4 @@ void av1_highbd_quantize_dc_facade(const tran_low_t *coeff_ptr,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_QUANTIZE_H_
|
||||
#endif // AOM_AV1_ENCODER_AV1_QUANTIZE_H_
|
||||
|
|
|
|||
316
third_party/aom/av1/encoder/bitstream.c
vendored
316
third_party/aom/av1/encoder/bitstream.c
vendored
|
|
@ -18,6 +18,7 @@
|
|||
#include "aom_dsp/binary_codes_writer.h"
|
||||
#include "aom_dsp/bitwriter_buffer.h"
|
||||
#include "aom_mem/aom_mem.h"
|
||||
#include "aom_ports/bitops.h"
|
||||
#include "aom_ports/mem_ops.h"
|
||||
#include "aom_ports/system_state.h"
|
||||
#if CONFIG_BITSTREAM_DEBUG
|
||||
|
|
@ -30,7 +31,6 @@
|
|||
#include "av1/common/entropymode.h"
|
||||
#include "av1/common/entropymv.h"
|
||||
#include "av1/common/mvref_common.h"
|
||||
#include "av1/common/odintrin.h"
|
||||
#include "av1/common/pred_common.h"
|
||||
#include "av1/common/reconinter.h"
|
||||
#include "av1/common/reconintra.h"
|
||||
|
|
@ -66,11 +66,11 @@ static void loop_restoration_write_sb_coeffs(const AV1_COMMON *const cm,
|
|||
aom_writer *const w, int plane,
|
||||
FRAME_COUNTS *counts);
|
||||
|
||||
static void write_intra_mode_kf(FRAME_CONTEXT *frame_ctx,
|
||||
const MB_MODE_INFO *mi,
|
||||
const MB_MODE_INFO *above_mi,
|
||||
const MB_MODE_INFO *left_mi,
|
||||
PREDICTION_MODE mode, aom_writer *w) {
|
||||
static void write_intra_y_mode_kf(FRAME_CONTEXT *frame_ctx,
|
||||
const MB_MODE_INFO *mi,
|
||||
const MB_MODE_INFO *above_mi,
|
||||
const MB_MODE_INFO *left_mi,
|
||||
PREDICTION_MODE mode, aom_writer *w) {
|
||||
assert(!is_intrabc_block(mi));
|
||||
(void)mi;
|
||||
aom_write_symbol(w, mode, get_y_mode_cdf(frame_ctx, above_mi, left_mi),
|
||||
|
|
@ -297,7 +297,7 @@ static void write_delta_qindex(const MACROBLOCKD *xd, int delta_qindex,
|
|||
DELTA_Q_PROBS + 1);
|
||||
|
||||
if (!smallval) {
|
||||
rem_bits = OD_ILOG_NZ(abs - 1) - 1;
|
||||
rem_bits = get_msb(abs - 1);
|
||||
thr = (1 << rem_bits) + 1;
|
||||
aom_write_literal(w, rem_bits - 1, 3);
|
||||
aom_write_literal(w, abs - thr, rem_bits);
|
||||
|
|
@ -326,7 +326,7 @@ static void write_delta_lflevel(const AV1_COMMON *cm, const MACROBLOCKD *xd,
|
|||
}
|
||||
|
||||
if (!smallval) {
|
||||
rem_bits = OD_ILOG_NZ(abs - 1) - 1;
|
||||
rem_bits = get_msb(abs - 1);
|
||||
thr = (1 << rem_bits) + 1;
|
||||
aom_write_literal(w, rem_bits - 1, 3);
|
||||
aom_write_literal(w, abs - thr, rem_bits);
|
||||
|
|
@ -836,8 +836,8 @@ void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
|
|||
}
|
||||
}
|
||||
|
||||
static void write_intra_mode(FRAME_CONTEXT *frame_ctx, BLOCK_SIZE bsize,
|
||||
PREDICTION_MODE mode, aom_writer *w) {
|
||||
static void write_intra_y_mode_nonkf(FRAME_CONTEXT *frame_ctx, BLOCK_SIZE bsize,
|
||||
PREDICTION_MODE mode, aom_writer *w) {
|
||||
aom_write_symbol(w, mode, frame_ctx->y_mode_cdf[size_group_lookup[bsize]],
|
||||
INTRA_MODES);
|
||||
}
|
||||
|
|
@ -933,45 +933,24 @@ static void write_inter_segment_id(AV1_COMP *cpi, aom_writer *w,
|
|||
}
|
||||
}
|
||||
|
||||
static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
|
||||
const int mi_col, aom_writer *w) {
|
||||
// If delta q is present, writes delta_q index.
|
||||
// Also writes delta_q loop filter levels, if present.
|
||||
static void write_delta_q_params(AV1_COMP *cpi, const int mi_row,
|
||||
const int mi_col, int skip, aom_writer *w) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
MACROBLOCK *const x = &cpi->td.mb;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
const struct segmentation *const seg = &cm->seg;
|
||||
struct segmentation_probs *const segp = &ec_ctx->seg;
|
||||
const MB_MODE_INFO *const mbmi = xd->mi[0];
|
||||
const MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
|
||||
const PREDICTION_MODE mode = mbmi->mode;
|
||||
const int segment_id = mbmi->segment_id;
|
||||
const BLOCK_SIZE bsize = mbmi->sb_type;
|
||||
const int allow_hp = cm->allow_high_precision_mv;
|
||||
const int is_inter = is_inter_block(mbmi);
|
||||
const int is_compound = has_second_ref(mbmi);
|
||||
int skip, ref;
|
||||
(void)mi_row;
|
||||
(void)mi_col;
|
||||
|
||||
write_inter_segment_id(cpi, w, seg, segp, mi_row, mi_col, 0, 1);
|
||||
|
||||
write_skip_mode(cm, xd, segment_id, mbmi, w);
|
||||
|
||||
assert(IMPLIES(mbmi->skip_mode, mbmi->skip));
|
||||
skip = mbmi->skip_mode ? 1 : write_skip(cm, xd, segment_id, mbmi, w);
|
||||
|
||||
write_inter_segment_id(cpi, w, seg, segp, mi_row, mi_col, skip, 0);
|
||||
|
||||
write_cdef(cm, xd, w, skip, mi_col, mi_row);
|
||||
|
||||
if (cm->delta_q_present_flag) {
|
||||
int super_block_upper_left =
|
||||
MACROBLOCK *const x = &cpi->td.mb;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
const MB_MODE_INFO *const mbmi = xd->mi[0];
|
||||
const BLOCK_SIZE bsize = mbmi->sb_type;
|
||||
const int super_block_upper_left =
|
||||
((mi_row & (cm->seq_params.mib_size - 1)) == 0) &&
|
||||
((mi_col & (cm->seq_params.mib_size - 1)) == 0);
|
||||
|
||||
if ((bsize != cm->seq_params.sb_size || skip == 0) &&
|
||||
super_block_upper_left) {
|
||||
assert(mbmi->current_qindex > 0);
|
||||
int reduced_delta_qindex =
|
||||
const int reduced_delta_qindex =
|
||||
(mbmi->current_qindex - xd->current_qindex) / cm->delta_q_res;
|
||||
write_delta_qindex(xd, reduced_delta_qindex, w);
|
||||
xd->current_qindex = mbmi->current_qindex;
|
||||
|
|
@ -996,37 +975,96 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void write_intra_prediction_modes(AV1_COMP *cpi, const int mi_row,
|
||||
const int mi_col, int is_keyframe,
|
||||
aom_writer *w) {
|
||||
const AV1_COMMON *const cm = &cpi->common;
|
||||
MACROBLOCK *const x = &cpi->td.mb;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
const MB_MODE_INFO *const mbmi = xd->mi[0];
|
||||
const PREDICTION_MODE mode = mbmi->mode;
|
||||
const BLOCK_SIZE bsize = mbmi->sb_type;
|
||||
|
||||
// Y mode.
|
||||
if (is_keyframe) {
|
||||
const MB_MODE_INFO *const above_mi = xd->above_mbmi;
|
||||
const MB_MODE_INFO *const left_mi = xd->left_mbmi;
|
||||
write_intra_y_mode_kf(ec_ctx, mbmi, above_mi, left_mi, mode, w);
|
||||
} else {
|
||||
write_intra_y_mode_nonkf(ec_ctx, bsize, mode, w);
|
||||
}
|
||||
|
||||
// Y angle delta.
|
||||
const int use_angle_delta = av1_use_angle_delta(bsize);
|
||||
if (use_angle_delta && av1_is_directional_mode(mode)) {
|
||||
write_angle_delta(w, mbmi->angle_delta[PLANE_TYPE_Y],
|
||||
ec_ctx->angle_delta_cdf[mode - V_PRED]);
|
||||
}
|
||||
|
||||
// UV mode and UV angle delta.
|
||||
if (!cm->seq_params.monochrome &&
|
||||
is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
|
||||
xd->plane[1].subsampling_y)) {
|
||||
const UV_PREDICTION_MODE uv_mode = mbmi->uv_mode;
|
||||
write_intra_uv_mode(ec_ctx, uv_mode, mode, is_cfl_allowed(xd), w);
|
||||
if (uv_mode == UV_CFL_PRED)
|
||||
write_cfl_alphas(ec_ctx, mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs, w);
|
||||
if (use_angle_delta && av1_is_directional_mode(get_uv_mode(uv_mode))) {
|
||||
write_angle_delta(w, mbmi->angle_delta[PLANE_TYPE_UV],
|
||||
ec_ctx->angle_delta_cdf[uv_mode - V_PRED]);
|
||||
}
|
||||
}
|
||||
|
||||
// Palette.
|
||||
if (av1_allow_palette(cm->allow_screen_content_tools, bsize)) {
|
||||
write_palette_mode_info(cm, xd, mbmi, mi_row, mi_col, w);
|
||||
}
|
||||
|
||||
// Filter intra.
|
||||
write_filter_intra_mode_info(cm, xd, mbmi, w);
|
||||
}
|
||||
|
||||
static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
|
||||
const int mi_col, aom_writer *w) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
MACROBLOCK *const x = &cpi->td.mb;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
const struct segmentation *const seg = &cm->seg;
|
||||
struct segmentation_probs *const segp = &ec_ctx->seg;
|
||||
const MB_MODE_INFO *const mbmi = xd->mi[0];
|
||||
const MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
|
||||
const PREDICTION_MODE mode = mbmi->mode;
|
||||
const int segment_id = mbmi->segment_id;
|
||||
const BLOCK_SIZE bsize = mbmi->sb_type;
|
||||
const int allow_hp = cm->allow_high_precision_mv;
|
||||
const int is_inter = is_inter_block(mbmi);
|
||||
const int is_compound = has_second_ref(mbmi);
|
||||
int ref;
|
||||
|
||||
write_inter_segment_id(cpi, w, seg, segp, mi_row, mi_col, 0, 1);
|
||||
|
||||
write_skip_mode(cm, xd, segment_id, mbmi, w);
|
||||
|
||||
assert(IMPLIES(mbmi->skip_mode, mbmi->skip));
|
||||
const int skip =
|
||||
mbmi->skip_mode ? 1 : write_skip(cm, xd, segment_id, mbmi, w);
|
||||
|
||||
write_inter_segment_id(cpi, w, seg, segp, mi_row, mi_col, skip, 0);
|
||||
|
||||
write_cdef(cm, xd, w, skip, mi_col, mi_row);
|
||||
|
||||
write_delta_q_params(cpi, mi_row, mi_col, skip, w);
|
||||
|
||||
if (!mbmi->skip_mode) write_is_inter(cm, xd, mbmi->segment_id, w, is_inter);
|
||||
|
||||
if (mbmi->skip_mode) return;
|
||||
|
||||
if (!is_inter) {
|
||||
write_intra_mode(ec_ctx, bsize, mode, w);
|
||||
const int use_angle_delta = av1_use_angle_delta(bsize);
|
||||
|
||||
if (use_angle_delta && av1_is_directional_mode(mode)) {
|
||||
write_angle_delta(w, mbmi->angle_delta[PLANE_TYPE_Y],
|
||||
ec_ctx->angle_delta_cdf[mode - V_PRED]);
|
||||
}
|
||||
|
||||
if (!cm->seq_params.monochrome &&
|
||||
is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
|
||||
xd->plane[1].subsampling_y)) {
|
||||
const UV_PREDICTION_MODE uv_mode = mbmi->uv_mode;
|
||||
write_intra_uv_mode(ec_ctx, uv_mode, mode, is_cfl_allowed(xd), w);
|
||||
if (uv_mode == UV_CFL_PRED)
|
||||
write_cfl_alphas(ec_ctx, mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs, w);
|
||||
if (use_angle_delta && av1_is_directional_mode(get_uv_mode(uv_mode))) {
|
||||
write_angle_delta(w, mbmi->angle_delta[PLANE_TYPE_UV],
|
||||
ec_ctx->angle_delta_cdf[uv_mode - V_PRED]);
|
||||
}
|
||||
}
|
||||
|
||||
if (av1_allow_palette(cm->allow_screen_content_tools, bsize))
|
||||
write_palette_mode_info(cm, xd, mbmi, mi_row, mi_col, w);
|
||||
|
||||
write_filter_intra_mode_info(cm, xd, mbmi, w);
|
||||
write_intra_prediction_modes(cpi, mi_row, mi_col, 0, w);
|
||||
} else {
|
||||
int16_t mode_ctx;
|
||||
|
||||
|
|
@ -1172,11 +1210,7 @@ static void write_mb_modes_kf(AV1_COMP *cpi, MACROBLOCKD *xd,
|
|||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
const struct segmentation *const seg = &cm->seg;
|
||||
struct segmentation_probs *const segp = &ec_ctx->seg;
|
||||
const MB_MODE_INFO *const above_mi = xd->above_mbmi;
|
||||
const MB_MODE_INFO *const left_mi = xd->left_mbmi;
|
||||
const MB_MODE_INFO *const mbmi = xd->mi[0];
|
||||
const BLOCK_SIZE bsize = mbmi->sb_type;
|
||||
const PREDICTION_MODE mode = mbmi->mode;
|
||||
|
||||
if (seg->segid_preskip && seg->update_map)
|
||||
write_segment_id(cpi, mbmi, w, seg, segp, mi_row, mi_col, 0);
|
||||
|
|
@ -1188,69 +1222,14 @@ static void write_mb_modes_kf(AV1_COMP *cpi, MACROBLOCKD *xd,
|
|||
|
||||
write_cdef(cm, xd, w, skip, mi_col, mi_row);
|
||||
|
||||
if (cm->delta_q_present_flag) {
|
||||
int super_block_upper_left =
|
||||
((mi_row & (cm->seq_params.mib_size - 1)) == 0) &&
|
||||
((mi_col & (cm->seq_params.mib_size - 1)) == 0);
|
||||
if ((bsize != cm->seq_params.sb_size || skip == 0) &&
|
||||
super_block_upper_left) {
|
||||
assert(mbmi->current_qindex > 0);
|
||||
int reduced_delta_qindex =
|
||||
(mbmi->current_qindex - xd->current_qindex) / cm->delta_q_res;
|
||||
write_delta_qindex(xd, reduced_delta_qindex, w);
|
||||
xd->current_qindex = mbmi->current_qindex;
|
||||
if (cm->delta_lf_present_flag) {
|
||||
if (cm->delta_lf_multi) {
|
||||
const int frame_lf_count =
|
||||
av1_num_planes(cm) > 1 ? FRAME_LF_COUNT : FRAME_LF_COUNT - 2;
|
||||
for (int lf_id = 0; lf_id < frame_lf_count; ++lf_id) {
|
||||
int reduced_delta_lflevel =
|
||||
(mbmi->delta_lf[lf_id] - xd->delta_lf[lf_id]) /
|
||||
cm->delta_lf_res;
|
||||
write_delta_lflevel(cm, xd, lf_id, reduced_delta_lflevel, w);
|
||||
xd->delta_lf[lf_id] = mbmi->delta_lf[lf_id];
|
||||
}
|
||||
} else {
|
||||
int reduced_delta_lflevel =
|
||||
(mbmi->delta_lf_from_base - xd->delta_lf_from_base) /
|
||||
cm->delta_lf_res;
|
||||
write_delta_lflevel(cm, xd, -1, reduced_delta_lflevel, w);
|
||||
xd->delta_lf_from_base = mbmi->delta_lf_from_base;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
write_delta_q_params(cpi, mi_row, mi_col, skip, w);
|
||||
|
||||
if (av1_allow_intrabc(cm)) {
|
||||
write_intrabc_info(xd, mbmi_ext, w);
|
||||
if (is_intrabc_block(mbmi)) return;
|
||||
}
|
||||
|
||||
write_intra_mode_kf(ec_ctx, mbmi, above_mi, left_mi, mode, w);
|
||||
|
||||
const int use_angle_delta = av1_use_angle_delta(bsize);
|
||||
if (use_angle_delta && av1_is_directional_mode(mode)) {
|
||||
write_angle_delta(w, mbmi->angle_delta[PLANE_TYPE_Y],
|
||||
ec_ctx->angle_delta_cdf[mode - V_PRED]);
|
||||
}
|
||||
|
||||
if (!cm->seq_params.monochrome &&
|
||||
is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
|
||||
xd->plane[1].subsampling_y)) {
|
||||
const UV_PREDICTION_MODE uv_mode = mbmi->uv_mode;
|
||||
write_intra_uv_mode(ec_ctx, uv_mode, mode, is_cfl_allowed(xd), w);
|
||||
if (uv_mode == UV_CFL_PRED)
|
||||
write_cfl_alphas(ec_ctx, mbmi->cfl_alpha_idx, mbmi->cfl_alpha_signs, w);
|
||||
if (use_angle_delta && av1_is_directional_mode(get_uv_mode(uv_mode))) {
|
||||
write_angle_delta(w, mbmi->angle_delta[PLANE_TYPE_UV],
|
||||
ec_ctx->angle_delta_cdf[uv_mode - V_PRED]);
|
||||
}
|
||||
}
|
||||
|
||||
if (av1_allow_palette(cm->allow_screen_content_tools, bsize))
|
||||
write_palette_mode_info(cm, xd, mbmi, mi_row, mi_col, w);
|
||||
|
||||
write_filter_intra_mode_info(cm, xd, mbmi, w);
|
||||
write_intra_prediction_modes(cpi, mi_row, mi_col, 1, w);
|
||||
}
|
||||
|
||||
#if CONFIG_RD_DEBUG
|
||||
|
|
@ -1549,10 +1528,10 @@ static void write_modes_b(AV1_COMP *cpi, const TileInfo *const tile,
|
|||
write_tx_size_vartx(xd, mbmi, max_tx_size, 0, idy, idx, w);
|
||||
} else {
|
||||
write_selected_tx_size(xd, w);
|
||||
set_txfm_ctxs(mbmi->tx_size, xd->n8_w, xd->n8_h, 0, xd);
|
||||
set_txfm_ctxs(mbmi->tx_size, xd->n4_w, xd->n4_h, 0, xd);
|
||||
}
|
||||
} else {
|
||||
set_txfm_ctxs(mbmi->tx_size, xd->n8_w, xd->n8_h,
|
||||
set_txfm_ctxs(mbmi->tx_size, xd->n4_w, xd->n4_h,
|
||||
skip && is_inter_block(mbmi), xd);
|
||||
}
|
||||
|
||||
|
|
@ -1694,15 +1673,14 @@ static void write_modes_sb(AV1_COMP *const cpi, const TileInfo *const tile,
|
|||
}
|
||||
|
||||
static void write_modes(AV1_COMP *const cpi, const TileInfo *const tile,
|
||||
aom_writer *const w, const TOKENEXTRA **tok,
|
||||
const TOKENEXTRA *const tok_end) {
|
||||
aom_writer *const w, int tile_row, int tile_col) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
MACROBLOCKD *const xd = &cpi->td.mb.e_mbd;
|
||||
const int mi_row_start = tile->mi_row_start;
|
||||
const int mi_row_end = tile->mi_row_end;
|
||||
const int mi_col_start = tile->mi_col_start;
|
||||
const int mi_col_end = tile->mi_col_end;
|
||||
int mi_row, mi_col;
|
||||
int mi_row, mi_col, sb_row_in_tile;
|
||||
|
||||
av1_zero_above_context(cm, xd, mi_col_start, mi_col_end, tile->tile_row);
|
||||
av1_init_above_context(cm, xd, tile->tile_row);
|
||||
|
|
@ -1716,13 +1694,21 @@ static void write_modes(AV1_COMP *const cpi, const TileInfo *const tile,
|
|||
|
||||
for (mi_row = mi_row_start; mi_row < mi_row_end;
|
||||
mi_row += cm->seq_params.mib_size) {
|
||||
sb_row_in_tile =
|
||||
(mi_row - tile->mi_row_start) >> cm->seq_params.mib_size_log2;
|
||||
const TOKENEXTRA *tok =
|
||||
cpi->tplist[tile_row][tile_col][sb_row_in_tile].start;
|
||||
const TOKENEXTRA *tok_end =
|
||||
tok + cpi->tplist[tile_row][tile_col][sb_row_in_tile].count;
|
||||
|
||||
av1_zero_left_context(xd);
|
||||
|
||||
for (mi_col = mi_col_start; mi_col < mi_col_end;
|
||||
mi_col += cm->seq_params.mib_size) {
|
||||
write_modes_sb(cpi, tile, w, tok, tok_end, mi_row, mi_col,
|
||||
write_modes_sb(cpi, tile, w, &tok, tok_end, mi_row, mi_col,
|
||||
cm->seq_params.sb_size);
|
||||
}
|
||||
assert(tok == cpi->tplist[tile_row][tile_col][sb_row_in_tile].stop);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2220,33 +2206,12 @@ static void write_ext_tile_info(const AV1_COMMON *const cm,
|
|||
}
|
||||
}
|
||||
|
||||
#if USE_GF16_MULTI_LAYER
|
||||
static int get_refresh_mask_gf16(AV1_COMP *cpi) {
|
||||
if (cpi->common.frame_type == KEY_FRAME || frame_is_sframe(&cpi->common))
|
||||
return 0xFF;
|
||||
|
||||
int refresh_mask = 0;
|
||||
|
||||
if (cpi->refresh_last_frame || cpi->refresh_golden_frame ||
|
||||
cpi->refresh_bwd_ref_frame || cpi->refresh_alt2_ref_frame ||
|
||||
cpi->refresh_alt_ref_frame) {
|
||||
assert(cpi->refresh_fb_idx >= 0 && cpi->refresh_fb_idx < REF_FRAMES);
|
||||
refresh_mask |= (1 << cpi->refresh_fb_idx);
|
||||
}
|
||||
|
||||
return refresh_mask;
|
||||
}
|
||||
#endif // USE_GF16_MULTI_LAYER
|
||||
|
||||
static int get_refresh_mask(AV1_COMP *cpi) {
|
||||
if ((cpi->common.frame_type == KEY_FRAME && cpi->common.show_frame) ||
|
||||
frame_is_sframe(&cpi->common))
|
||||
return 0xFF;
|
||||
|
||||
int refresh_mask = 0;
|
||||
#if USE_GF16_MULTI_LAYER
|
||||
if (cpi->rc.baseline_gf_interval == 16) return get_refresh_mask_gf16(cpi);
|
||||
#endif // USE_GF16_MULTI_LAYER
|
||||
|
||||
// NOTE(zoeliu): When LAST_FRAME is to get refreshed, the decoder will be
|
||||
// notified to get LAST3_FRAME refreshed and then the virtual indexes for all
|
||||
|
|
@ -2281,8 +2246,13 @@ static int get_refresh_mask(AV1_COMP *cpi) {
|
|||
// Note: This is highly specific to the use of ARF as a forward reference,
|
||||
// and this needs to be generalized as other uses are implemented
|
||||
// (like RTC/temporal scalability).
|
||||
return refresh_mask |
|
||||
(cpi->refresh_golden_frame << cpi->ref_fb_idx[ALTREF_FRAME - 1]);
|
||||
|
||||
if (cpi->preserve_arf_as_gld) {
|
||||
return refresh_mask;
|
||||
} else {
|
||||
return refresh_mask |
|
||||
(cpi->refresh_golden_frame << cpi->ref_fb_idx[ALTREF_FRAME - 1]);
|
||||
}
|
||||
} else {
|
||||
const int arf_idx = cpi->ref_fb_idx[ALTREF_FRAME - 1];
|
||||
return refresh_mask |
|
||||
|
|
@ -2574,9 +2544,9 @@ static void write_film_grain_params(AV1_COMP *cpi,
|
|||
|
||||
aom_wb_write_literal(wb, pars->random_seed, 16);
|
||||
|
||||
pars->random_seed += 3245; // For film grain test vectors purposes
|
||||
pars->random_seed += 3381; // Changing random seed for film grain
|
||||
if (!pars->random_seed) // Random seed should not be zero
|
||||
pars->random_seed += 1735;
|
||||
pars->random_seed += 7391;
|
||||
if (cm->frame_type == INTER_FRAME)
|
||||
aom_wb_write_bit(wb, pars->update_parameters);
|
||||
else
|
||||
|
|
@ -2685,7 +2655,8 @@ static void write_sb_size(SequenceHeader *seq_params,
|
|||
aom_wb_write_bit(wb, seq_params->sb_size == BLOCK_128X128 ? 1 : 0);
|
||||
}
|
||||
|
||||
void write_sequence_header(AV1_COMP *cpi, struct aom_write_bit_buffer *wb) {
|
||||
static void write_sequence_header(AV1_COMP *cpi,
|
||||
struct aom_write_bit_buffer *wb) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
SequenceHeader *seq_params = &cm->seq_params;
|
||||
|
||||
|
|
@ -2695,8 +2666,10 @@ void write_sequence_header(AV1_COMP *cpi, struct aom_write_bit_buffer *wb) {
|
|||
int max_frame_height = cpi->oxcf.forced_max_frame_height
|
||||
? cpi->oxcf.forced_max_frame_height
|
||||
: cpi->oxcf.height;
|
||||
// max((int)ceil(log2(max_frame_width)), 1)
|
||||
const int num_bits_width =
|
||||
(max_frame_width > 1) ? get_msb(max_frame_width - 1) + 1 : 1;
|
||||
// max((int)ceil(log2(max_frame_height)), 1)
|
||||
const int num_bits_height =
|
||||
(max_frame_height > 1) ? get_msb(max_frame_height - 1) + 1 : 1;
|
||||
assert(num_bits_width <= 16);
|
||||
|
|
@ -2954,7 +2927,7 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
|
|||
assert(cm->frame_type == KEY_FRAME);
|
||||
}
|
||||
if (!seq_params->reduced_still_picture_hdr) {
|
||||
if (cm->show_existing_frame) {
|
||||
if (encode_show_existing_frame(cm)) {
|
||||
RefCntBuffer *const frame_bufs = cm->buffer_pool->frame_bufs;
|
||||
const int frame_to_show = cm->ref_frame_map[cpi->existing_fb_idx_to_show];
|
||||
|
||||
|
|
@ -3254,14 +3227,14 @@ static void write_uncompressed_header_obu(AV1_COMP *cpi,
|
|||
if (cm->base_qindex > 0) {
|
||||
aom_wb_write_bit(wb, cm->delta_q_present_flag);
|
||||
if (cm->delta_q_present_flag) {
|
||||
aom_wb_write_literal(wb, OD_ILOG_NZ(cm->delta_q_res) - 1, 2);
|
||||
aom_wb_write_literal(wb, get_msb(cm->delta_q_res), 2);
|
||||
xd->current_qindex = cm->base_qindex;
|
||||
if (cm->allow_intrabc)
|
||||
assert(cm->delta_lf_present_flag == 0);
|
||||
else
|
||||
aom_wb_write_bit(wb, cm->delta_lf_present_flag);
|
||||
if (cm->delta_lf_present_flag) {
|
||||
aom_wb_write_literal(wb, OD_ILOG_NZ(cm->delta_lf_res) - 1, 2);
|
||||
aom_wb_write_literal(wb, get_msb(cm->delta_lf_res), 2);
|
||||
aom_wb_write_bit(wb, cm->delta_lf_multi);
|
||||
av1_reset_loop_filter_delta(xd, av1_num_planes(cm));
|
||||
}
|
||||
|
|
@ -3508,7 +3481,7 @@ static void write_bitstream_level(BitstreamLevel bl,
|
|||
aom_wb_write_literal(wb, seq_level_idx, LEVEL_BITS);
|
||||
}
|
||||
|
||||
static uint32_t write_sequence_header_obu(AV1_COMP *cpi, uint8_t *const dst) {
|
||||
uint32_t write_sequence_header_obu(AV1_COMP *cpi, uint8_t *const dst) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
struct aom_write_bit_buffer wb = { dst, 0 };
|
||||
uint32_t size = 0;
|
||||
|
|
@ -3619,7 +3592,6 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
|
|||
AV1_COMMON *const cm = &cpi->common;
|
||||
aom_writer mode_bc;
|
||||
int tile_row, tile_col;
|
||||
TOKENEXTRA *(*const tok_buffers)[MAX_TILE_COLS] = cpi->tile_tok;
|
||||
TileBufferEnc(*const tile_buffers)[MAX_TILE_COLS] = cpi->tile_buffers;
|
||||
uint32_t total_size = 0;
|
||||
const int tile_cols = cm->tile_cols;
|
||||
|
|
@ -3684,8 +3656,6 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
|
|||
|
||||
for (tile_row = 0; tile_row < tile_rows; tile_row++) {
|
||||
TileBufferEnc *const buf = &tile_buffers[tile_row][tile_col];
|
||||
const TOKENEXTRA *tok = tok_buffers[tile_row][tile_col];
|
||||
const TOKENEXTRA *tok_end = tok + cpi->tok_count[tile_row][tile_col];
|
||||
const int data_offset = have_tiles ? 4 : 0;
|
||||
const int tile_idx = tile_row * tile_cols + tile_col;
|
||||
TileDataEnc *this_tile = &cpi->tile_data[tile_idx];
|
||||
|
|
@ -3703,8 +3673,7 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
|
|||
mode_bc.allow_update_cdf =
|
||||
mode_bc.allow_update_cdf && !cm->disable_cdf_update;
|
||||
aom_start_encode(&mode_bc, buf->data + data_offset);
|
||||
write_modes(cpi, &tile_info, &mode_bc, &tok, tok_end);
|
||||
assert(tok == tok_end);
|
||||
write_modes(cpi, &tile_info, &mode_bc, tile_row, tile_col);
|
||||
aom_stop_encode(&mode_bc);
|
||||
tile_size = mode_bc.pos;
|
||||
buf->size = tile_size;
|
||||
|
|
@ -3794,8 +3763,6 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
|
|||
const int tile_idx = tile_row * tile_cols + tile_col;
|
||||
TileBufferEnc *const buf = &tile_buffers[tile_row][tile_col];
|
||||
TileDataEnc *this_tile = &cpi->tile_data[tile_idx];
|
||||
const TOKENEXTRA *tok = tok_buffers[tile_row][tile_col];
|
||||
const TOKENEXTRA *tok_end = tok + cpi->tok_count[tile_row][tile_col];
|
||||
int is_last_tile_in_tg = 0;
|
||||
|
||||
if (new_tg) {
|
||||
|
|
@ -3847,7 +3814,7 @@ static uint32_t write_tiles_in_tg_obus(AV1_COMP *const cpi, uint8_t *const dst,
|
|||
av1_reset_loop_restoration(&cpi->td.mb.e_mbd, num_planes);
|
||||
|
||||
aom_start_encode(&mode_bc, dst + total_size);
|
||||
write_modes(cpi, &tile_info, &mode_bc, &tok, tok_end);
|
||||
write_modes(cpi, &tile_info, &mode_bc, tile_row, tile_col);
|
||||
aom_stop_encode(&mode_bc);
|
||||
tile_size = mode_bc.pos;
|
||||
assert(tile_size >= AV1_MIN_TILE_SIZE_BYTES);
|
||||
|
|
@ -3990,7 +3957,8 @@ int av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
|
|||
data += obu_header_size + obu_payload_size + length_field_size;
|
||||
}
|
||||
|
||||
const int write_frame_header = (cm->num_tg > 1 || cm->show_existing_frame);
|
||||
const int write_frame_header =
|
||||
(cm->num_tg > 1 || encode_show_existing_frame(cm));
|
||||
struct aom_write_bit_buffer saved_wb;
|
||||
if (write_frame_header) {
|
||||
// Write Frame Header OBU.
|
||||
|
|
@ -4017,7 +3985,7 @@ int av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dst, size_t *size) {
|
|||
saved_wb.bit_buffer += length_field_size;
|
||||
}
|
||||
|
||||
if (cm->show_existing_frame) {
|
||||
if (encode_show_existing_frame(cm)) {
|
||||
data_size = 0;
|
||||
} else {
|
||||
// Each tile group obu will be preceded by 4-byte size of the tile group
|
||||
|
|
|
|||
16
third_party/aom/av1/encoder/bitstream.h
vendored
16
third_party/aom/av1/encoder/bitstream.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_BITSTREAM_H_
|
||||
#define AV1_ENCODER_BITSTREAM_H_
|
||||
#ifndef AOM_AV1_ENCODER_BITSTREAM_H_
|
||||
#define AOM_AV1_ENCODER_BITSTREAM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -20,8 +20,13 @@ extern "C" {
|
|||
|
||||
struct aom_write_bit_buffer;
|
||||
|
||||
void write_sequence_header(AV1_COMP *cpi, struct aom_write_bit_buffer *wb);
|
||||
// Writes only the OBU Sequence Header payload, and returns the size of the
|
||||
// payload written to 'dst'. This function does not write the OBU header, the
|
||||
// optional extension, or the OBU size to 'dst'.
|
||||
uint32_t write_sequence_header_obu(AV1_COMP *cpi, uint8_t *const dst);
|
||||
|
||||
// Writes the OBU header byte, and the OBU header extension byte when
|
||||
// 'obu_extension' is non-zero. Returns number of bytes written to 'dst'.
|
||||
uint32_t write_obu_header(OBU_TYPE obu_type, int obu_extension,
|
||||
uint8_t *const dst);
|
||||
|
||||
|
|
@ -32,8 +37,7 @@ int av1_pack_bitstream(AV1_COMP *const cpi, uint8_t *dest, size_t *size);
|
|||
|
||||
static INLINE int av1_preserve_existing_gf(AV1_COMP *cpi) {
|
||||
// Do not swap gf and arf indices for internal overlay frames
|
||||
return !cpi->multi_arf_allowed && cpi->rc.is_src_frame_alt_ref &&
|
||||
!cpi->rc.is_src_frame_ext_arf;
|
||||
return cpi->rc.is_src_frame_alt_ref && !cpi->rc.is_src_frame_ext_arf;
|
||||
}
|
||||
|
||||
void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
|
||||
|
|
@ -44,4 +48,4 @@ void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_BITSTREAM_H_
|
||||
#endif // AOM_AV1_ENCODER_BITSTREAM_H_
|
||||
|
|
|
|||
53
third_party/aom/av1/encoder/block.h
vendored
53
third_party/aom/av1/encoder/block.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_BLOCK_H_
|
||||
#define AV1_ENCODER_BLOCK_H_
|
||||
#ifndef AOM_AV1_ENCODER_BLOCK_H_
|
||||
#define AOM_AV1_ENCODER_BLOCK_H_
|
||||
|
||||
#include "av1/common/entropymv.h"
|
||||
#include "av1/common/entropy.h"
|
||||
|
|
@ -170,6 +170,7 @@ typedef struct {
|
|||
InterpFilters filters;
|
||||
int_mv mv[2];
|
||||
int8_t ref_frames[2];
|
||||
COMPOUND_TYPE comp_type;
|
||||
} INTERPOLATION_FILTER_STATS;
|
||||
|
||||
typedef struct macroblock MACROBLOCK;
|
||||
|
|
@ -254,6 +255,19 @@ struct macroblock {
|
|||
|
||||
PALETTE_BUFFER *palette_buffer;
|
||||
|
||||
CONV_BUF_TYPE *tmp_conv_dst;
|
||||
uint8_t *tmp_obmc_bufs[2];
|
||||
|
||||
// buffer for hash value calculation of a block
|
||||
// used only in av1_get_block_hash_value()
|
||||
// [first hash/second hash]
|
||||
// [two buffers used ping-pong]
|
||||
uint32_t *hash_value_buffer[2][2];
|
||||
|
||||
CRC_CALCULATOR crc_calculator1;
|
||||
CRC_CALCULATOR crc_calculator2;
|
||||
int g_crc_initialized;
|
||||
|
||||
// These define limits to motion vector components to prevent them
|
||||
// from extending outside the UMV borders
|
||||
MvLimits mv_limits;
|
||||
|
|
@ -344,7 +358,6 @@ struct macroblock {
|
|||
#if CONFIG_DIST_8X8
|
||||
int using_dist_8x8;
|
||||
aom_tune_metric tune_metric;
|
||||
DECLARE_ALIGNED(16, int16_t, pred_luma[MAX_SB_SQUARE]);
|
||||
#endif // CONFIG_DIST_8X8
|
||||
int comp_idx_cost[COMP_INDEX_CONTEXTS][2];
|
||||
int comp_group_idx_cost[COMP_GROUP_IDX_CONTEXTS][2];
|
||||
|
|
@ -352,6 +365,8 @@ struct macroblock {
|
|||
int tx_search_prune[EXT_TX_SET_TYPES];
|
||||
int must_find_valid_partition;
|
||||
int tx_split_prune_flag; // Flag to skip tx split RD search.
|
||||
int recalc_luma_mc_data; // Flag to indicate recalculation of MC data during
|
||||
// interpolation filter search
|
||||
};
|
||||
|
||||
static INLINE int is_rect_tx_allowed_bsize(BLOCK_SIZE bsize) {
|
||||
|
|
@ -400,8 +415,38 @@ static INLINE int tx_size_to_depth(TX_SIZE tx_size, BLOCK_SIZE bsize) {
|
|||
return depth;
|
||||
}
|
||||
|
||||
static INLINE void set_blk_skip(MACROBLOCK *x, int plane, int blk_idx,
|
||||
int skip) {
|
||||
if (skip)
|
||||
x->blk_skip[blk_idx] |= 1UL << plane;
|
||||
else
|
||||
x->blk_skip[blk_idx] &= ~(1UL << plane);
|
||||
#ifndef NDEBUG
|
||||
// Set chroma planes to uninitialized states when luma is set to check if
|
||||
// it will be set later
|
||||
if (plane == 0) {
|
||||
x->blk_skip[blk_idx] |= 1UL << (1 + 4);
|
||||
x->blk_skip[blk_idx] |= 1UL << (2 + 4);
|
||||
}
|
||||
|
||||
// Clear the initialization checking bit
|
||||
x->blk_skip[blk_idx] &= ~(1UL << (plane + 4));
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE int is_blk_skip(MACROBLOCK *x, int plane, int blk_idx) {
|
||||
#ifndef NDEBUG
|
||||
// Check if this is initialized
|
||||
assert(!(x->blk_skip[blk_idx] & (1UL << (plane + 4))));
|
||||
|
||||
// The magic number is 0x77, this is to test if there is garbage data
|
||||
assert((x->blk_skip[blk_idx] & 0x88) == 0);
|
||||
#endif
|
||||
return (x->blk_skip[blk_idx] >> plane) & 1;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_BLOCK_H_
|
||||
#endif // AOM_AV1_ENCODER_BLOCK_H_
|
||||
|
|
|
|||
1
third_party/aom/av1/encoder/blockiness.c
vendored
1
third_party/aom/av1/encoder/blockiness.c
vendored
|
|
@ -16,7 +16,6 @@
|
|||
#include "av1/common/common.h"
|
||||
#include "av1/common/filter.h"
|
||||
#include "aom/aom_integer.h"
|
||||
#include "aom_dsp/aom_convolve.h"
|
||||
#include "aom_dsp/aom_filter.h"
|
||||
#include "aom_ports/mem.h"
|
||||
#include "aom_ports/system_state.h"
|
||||
|
|
|
|||
17
third_party/aom/av1/encoder/context_tree.c
vendored
17
third_party/aom/av1/encoder/context_tree.c
vendored
|
|
@ -175,14 +175,15 @@ void av1_setup_pc_tree(AV1_COMMON *cm, ThreadData *td) {
|
|||
}
|
||||
|
||||
void av1_free_pc_tree(ThreadData *td, const int num_planes) {
|
||||
const int tree_nodes_inc = 1024;
|
||||
|
||||
const int tree_nodes = tree_nodes_inc + 256 + 64 + 16 + 4 + 1;
|
||||
int i;
|
||||
for (i = 0; i < tree_nodes; ++i)
|
||||
free_tree_contexts(&td->pc_tree[i], num_planes);
|
||||
aom_free(td->pc_tree);
|
||||
td->pc_tree = NULL;
|
||||
if (td->pc_tree != NULL) {
|
||||
const int tree_nodes_inc = 1024;
|
||||
const int tree_nodes = tree_nodes_inc + 256 + 64 + 16 + 4 + 1;
|
||||
for (int i = 0; i < tree_nodes; ++i) {
|
||||
free_tree_contexts(&td->pc_tree[i], num_planes);
|
||||
}
|
||||
aom_free(td->pc_tree);
|
||||
td->pc_tree = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void av1_copy_tree_context(PICK_MODE_CONTEXT *dst_ctx,
|
||||
|
|
|
|||
8
third_party/aom/av1/encoder/context_tree.h
vendored
8
third_party/aom/av1/encoder/context_tree.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_CONTEXT_TREE_H_
|
||||
#define AV1_ENCODER_CONTEXT_TREE_H_
|
||||
#ifndef AOM_AV1_ENCODER_CONTEXT_TREE_H_
|
||||
#define AOM_AV1_ENCODER_CONTEXT_TREE_H_
|
||||
|
||||
#include "av1/common/blockd.h"
|
||||
#include "av1/encoder/block.h"
|
||||
|
|
@ -56,6 +56,8 @@ typedef struct {
|
|||
int hybrid_pred_diff;
|
||||
int comp_pred_diff;
|
||||
int single_pred_diff;
|
||||
// Skip certain ref frames during RD search of rectangular partitions.
|
||||
int skip_ref_frame_mask;
|
||||
|
||||
// TODO(jingning) Use RD_COST struct here instead. This involves a boarder
|
||||
// scope of refactoring.
|
||||
|
|
@ -109,4 +111,4 @@ void av1_copy_tree_context(PICK_MODE_CONTEXT *dst_ctx,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* AV1_ENCODER_CONTEXT_TREE_H_ */
|
||||
#endif // AOM_AV1_ENCODER_CONTEXT_TREE_H_
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/corner_detect.h
vendored
6
third_party/aom/av1/encoder/corner_detect.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_CORNER_DETECT_H_
|
||||
#define AV1_ENCODER_CORNER_DETECT_H_
|
||||
#ifndef AOM_AV1_ENCODER_CORNER_DETECT_H_
|
||||
#define AOM_AV1_ENCODER_CORNER_DETECT_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -19,4 +19,4 @@
|
|||
int fast_corner_detect(unsigned char *buf, int width, int height, int stride,
|
||||
int *points, int max_points);
|
||||
|
||||
#endif // AV1_ENCODER_CORNER_DETECT_H_
|
||||
#endif // AOM_AV1_ENCODER_CORNER_DETECT_H_
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/corner_match.h
vendored
6
third_party/aom/av1/encoder/corner_match.h
vendored
|
|
@ -8,8 +8,8 @@
|
|||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
#ifndef AV1_ENCODER_CORNER_MATCH_H_
|
||||
#define AV1_ENCODER_CORNER_MATCH_H_
|
||||
#ifndef AOM_AV1_ENCODER_CORNER_MATCH_H_
|
||||
#define AOM_AV1_ENCODER_CORNER_MATCH_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -30,4 +30,4 @@ int determine_correspondence(unsigned char *frm, int *frm_corners,
|
|||
int height, int frm_stride, int ref_stride,
|
||||
int *correspondence_pts);
|
||||
|
||||
#endif // AV1_ENCODER_CORNER_MATCH_H_
|
||||
#endif // AOM_AV1_ENCODER_CORNER_MATCH_H_
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/cost.h
vendored
6
third_party/aom/av1/encoder/cost.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_COST_H_
|
||||
#define AV1_ENCODER_COST_H_
|
||||
#ifndef AOM_AV1_ENCODER_COST_H_
|
||||
#define AOM_AV1_ENCODER_COST_H_
|
||||
|
||||
#include "aom_dsp/prob.h"
|
||||
#include "aom/aom_integer.h"
|
||||
|
|
@ -44,4 +44,4 @@ void av1_cost_tokens_from_cdf(int *costs, const aom_cdf_prob *cdf,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_COST_H_
|
||||
#endif // AOM_AV1_ENCODER_COST_H_
|
||||
|
|
|
|||
5
third_party/aom/av1/encoder/dwt.h
vendored
5
third_party/aom/av1/encoder/dwt.h
vendored
|
|
@ -9,6 +9,9 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AOM_AV1_ENCODER_DWT_H_
|
||||
#define AOM_AV1_ENCODER_DWT_H_
|
||||
|
||||
#include "av1/common/common.h"
|
||||
#include "av1/common/enums.h"
|
||||
|
||||
|
|
@ -18,3 +21,5 @@ void av1_fdwt8x8(tran_low_t *input, tran_low_t *output, int stride);
|
|||
void av1_fdwt8x8_uint8_input_c(uint8_t *input, tran_low_t *output, int stride,
|
||||
int hbd);
|
||||
int av1_haar_ac_sad_8x8_uint8_input(uint8_t *input, int stride, int hbd);
|
||||
|
||||
#endif // AOM_AV1_ENCODER_DWT_H_
|
||||
|
|
|
|||
1075
third_party/aom/av1/encoder/encodeframe.c
vendored
1075
third_party/aom/av1/encoder/encodeframe.c
vendored
File diff suppressed because it is too large
Load diff
11
third_party/aom/av1/encoder/encodeframe.h
vendored
11
third_party/aom/av1/encoder/encodeframe.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_ENCODEFRAME_H_
|
||||
#define AV1_ENCODER_ENCODEFRAME_H_
|
||||
#ifndef AOM_AV1_ENCODER_ENCODEFRAME_H_
|
||||
#define AOM_AV1_ENCODER_ENCODEFRAME_H_
|
||||
|
||||
#include "aom/aom_integer.h"
|
||||
#include "av1/common/blockd.h"
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define DELTAQ_MODULATION 0 // 0: variance based, 1: wavelet AC energy based
|
||||
#define DELTAQ_MODULATION 1 // 0: variance based, 1: wavelet AC energy based
|
||||
|
||||
struct macroblock;
|
||||
struct yv12_buffer_config;
|
||||
|
|
@ -33,12 +33,15 @@ void av1_setup_src_planes(struct macroblock *x,
|
|||
|
||||
void av1_encode_frame(struct AV1_COMP *cpi);
|
||||
|
||||
void av1_alloc_tile_data(struct AV1_COMP *cpi);
|
||||
void av1_init_tile_data(struct AV1_COMP *cpi);
|
||||
void av1_encode_tile(struct AV1_COMP *cpi, struct ThreadData *td, int tile_row,
|
||||
int tile_col);
|
||||
void av1_encode_sb_row(struct AV1_COMP *cpi, struct ThreadData *td,
|
||||
int tile_row, int tile_col, int mi_row);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_ENCODEFRAME_H_
|
||||
#endif // AOM_AV1_ENCODER_ENCODEFRAME_H_
|
||||
|
|
|
|||
71
third_party/aom/av1/encoder/encodemb.c
vendored
71
third_party/aom/av1/encoder/encodemb.c
vendored
|
|
@ -222,11 +222,8 @@ static void encode_block(int plane, int block, int blk_row, int blk_col,
|
|||
|
||||
a = &args->ta[blk_col];
|
||||
l = &args->tl[blk_row];
|
||||
// Assert not magic number (uninitialized).
|
||||
assert(plane != 0 || x->blk_skip[blk_row * bw + blk_col] != 234);
|
||||
|
||||
if ((plane != 0 || x->blk_skip[blk_row * bw + blk_col] == 0) &&
|
||||
!mbmi->skip_mode) {
|
||||
if (!is_blk_skip(x, plane, blk_row * bw + blk_col) && !mbmi->skip_mode) {
|
||||
TX_TYPE tx_type = av1_get_tx_type(pd->plane_type, xd, blk_row, blk_col,
|
||||
tx_size, cm->reduced_tx_set_used);
|
||||
if (args->enable_optimize_b) {
|
||||
|
|
@ -350,6 +347,66 @@ static void encode_block_inter(int plane, int block, int blk_row, int blk_col,
|
|||
}
|
||||
}
|
||||
|
||||
void av1_foreach_transformed_block_in_plane(
|
||||
const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane,
|
||||
foreach_transformed_block_visitor visit, void *arg) {
|
||||
const struct macroblockd_plane *const pd = &xd->plane[plane];
|
||||
// block and transform sizes, in number of 4x4 blocks log 2 ("*_b")
|
||||
// 4x4=0, 8x8=2, 16x16=4, 32x32=6, 64x64=8
|
||||
// transform size varies per plane, look it up in a common way.
|
||||
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
|
||||
const BLOCK_SIZE plane_bsize =
|
||||
get_plane_block_size(bsize, pd->subsampling_x, pd->subsampling_y);
|
||||
const uint8_t txw_unit = tx_size_wide_unit[tx_size];
|
||||
const uint8_t txh_unit = tx_size_high_unit[tx_size];
|
||||
const int step = txw_unit * txh_unit;
|
||||
int i = 0, r, c;
|
||||
|
||||
// If mb_to_right_edge is < 0 we are in a situation in which
|
||||
// the current block size extends into the UMV and we won't
|
||||
// visit the sub blocks that are wholly within the UMV.
|
||||
const int max_blocks_wide = max_block_wide(xd, plane_bsize, plane);
|
||||
const int max_blocks_high = max_block_high(xd, plane_bsize, plane);
|
||||
|
||||
int blk_row, blk_col;
|
||||
|
||||
const BLOCK_SIZE max_unit_bsize =
|
||||
get_plane_block_size(BLOCK_64X64, pd->subsampling_x, pd->subsampling_y);
|
||||
int mu_blocks_wide = block_size_wide[max_unit_bsize] >> tx_size_wide_log2[0];
|
||||
int mu_blocks_high = block_size_high[max_unit_bsize] >> tx_size_high_log2[0];
|
||||
mu_blocks_wide = AOMMIN(max_blocks_wide, mu_blocks_wide);
|
||||
mu_blocks_high = AOMMIN(max_blocks_high, mu_blocks_high);
|
||||
|
||||
// Keep track of the row and column of the blocks we use so that we know
|
||||
// if we are in the unrestricted motion border.
|
||||
for (r = 0; r < max_blocks_high; r += mu_blocks_high) {
|
||||
const int unit_height = AOMMIN(mu_blocks_high + r, max_blocks_high);
|
||||
// Skip visiting the sub blocks that are wholly within the UMV.
|
||||
for (c = 0; c < max_blocks_wide; c += mu_blocks_wide) {
|
||||
const int unit_width = AOMMIN(mu_blocks_wide + c, max_blocks_wide);
|
||||
for (blk_row = r; blk_row < unit_height; blk_row += txh_unit) {
|
||||
for (blk_col = c; blk_col < unit_width; blk_col += txw_unit) {
|
||||
visit(plane, i, blk_row, blk_col, plane_bsize, tx_size, arg);
|
||||
i += step;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void av1_foreach_transformed_block(const MACROBLOCKD *const xd,
|
||||
BLOCK_SIZE bsize, int mi_row, int mi_col,
|
||||
foreach_transformed_block_visitor visit,
|
||||
void *arg, const int num_planes) {
|
||||
for (int plane = 0; plane < num_planes; ++plane) {
|
||||
if (!is_chroma_reference(mi_row, mi_col, bsize,
|
||||
xd->plane[plane].subsampling_x,
|
||||
xd->plane[plane].subsampling_y))
|
||||
continue;
|
||||
av1_foreach_transformed_block_in_plane(xd, bsize, plane, visit, arg);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct encode_block_pass1_args {
|
||||
AV1_COMMON *cm;
|
||||
MACROBLOCK *x;
|
||||
|
|
@ -382,7 +439,7 @@ static void encode_block_pass1(int plane, int block, int blk_row, int blk_col,
|
|||
txfm_param.tx_set_type = av1_get_ext_tx_set_type(
|
||||
txfm_param.tx_size, is_inter_block(xd->mi[0]), cm->reduced_tx_set_used);
|
||||
if (txfm_param.is_hbd) {
|
||||
av1_highbd_inv_txfm_add_4x4(dqcoeff, dst, pd->dst.stride, &txfm_param);
|
||||
av1_highbd_inv_txfm_add(dqcoeff, dst, pd->dst.stride, &txfm_param);
|
||||
return;
|
||||
}
|
||||
av1_inv_txfm_add(dqcoeff, dst, pd->dst.stride, &txfm_param);
|
||||
|
|
@ -513,9 +570,7 @@ void av1_encode_block_intra(int plane, int block, int blk_row, int blk_col,
|
|||
av1_predict_intra_block_facade(cm, xd, plane, blk_col, blk_row, tx_size);
|
||||
|
||||
const int bw = block_size_wide[plane_bsize] >> tx_size_wide_log2[0];
|
||||
// Assert not magic number (uninitialized).
|
||||
assert(plane != 0 || x->blk_skip[blk_row * bw + blk_col] != 234);
|
||||
if (plane == 0 && x->blk_skip[blk_row * bw + blk_col]) {
|
||||
if (plane == 0 && is_blk_skip(x, plane, blk_row * bw + blk_col)) {
|
||||
*eob = 0;
|
||||
p->txb_entropy_ctx[block] = 0;
|
||||
} else {
|
||||
|
|
|
|||
17
third_party/aom/av1/encoder/encodemb.h
vendored
17
third_party/aom/av1/encoder/encodemb.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_ENCODEMB_H_
|
||||
#define AV1_ENCODER_ENCODEMB_H_
|
||||
#ifndef AOM_AV1_ENCODER_ENCODEMB_H_
|
||||
#define AOM_AV1_ENCODER_ENCODEMB_H_
|
||||
|
||||
#include "config/aom_config.h"
|
||||
|
||||
|
|
@ -47,7 +47,18 @@ typedef enum AV1_XFORM_QUANT {
|
|||
|
||||
void av1_encode_sb(const struct AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
|
||||
int mi_row, int mi_col, RUN_TYPE dry_run);
|
||||
|
||||
void av1_foreach_transformed_block_in_plane(
|
||||
const MACROBLOCKD *const xd, BLOCK_SIZE bsize, int plane,
|
||||
foreach_transformed_block_visitor visit, void *arg);
|
||||
|
||||
void av1_foreach_transformed_block(const MACROBLOCKD *const xd,
|
||||
BLOCK_SIZE bsize, int mi_row, int mi_col,
|
||||
foreach_transformed_block_visitor visit,
|
||||
void *arg, const int num_planes);
|
||||
|
||||
void av1_encode_sby_pass1(AV1_COMMON *cm, MACROBLOCK *x, BLOCK_SIZE bsize);
|
||||
|
||||
void av1_xform_quant(const AV1_COMMON *cm, MACROBLOCK *x, int plane, int block,
|
||||
int blk_row, int blk_col, BLOCK_SIZE plane_bsize,
|
||||
TX_SIZE tx_size, TX_TYPE tx_type,
|
||||
|
|
@ -82,4 +93,4 @@ void av1_encode_intra_block_plane(const struct AV1_COMP *cpi, MACROBLOCK *x,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_ENCODEMB_H_
|
||||
#endif // AOM_AV1_ENCODER_ENCODEMB_H_
|
||||
|
|
|
|||
26
third_party/aom/av1/encoder/encodemv.c
vendored
26
third_party/aom/av1/encoder/encodemv.c
vendored
|
|
@ -18,19 +18,37 @@
|
|||
#include "av1/encoder/encodemv.h"
|
||||
|
||||
#include "aom_dsp/aom_dsp_common.h"
|
||||
#include "aom_ports/bitops.h"
|
||||
|
||||
static INLINE int mv_class_base(MV_CLASS_TYPE c) {
|
||||
return c ? CLASS0_SIZE << (c + 2) : 0;
|
||||
}
|
||||
|
||||
// If n != 0, returns the floor of log base 2 of n. If n == 0, returns 0.
|
||||
static INLINE uint8_t log_in_base_2(unsigned int n) {
|
||||
// get_msb() is only valid when n != 0.
|
||||
return n == 0 ? 0 : get_msb(n);
|
||||
}
|
||||
|
||||
static INLINE MV_CLASS_TYPE get_mv_class(int z, int *offset) {
|
||||
const MV_CLASS_TYPE c = (z >= CLASS0_SIZE * 4096)
|
||||
? MV_CLASS_10
|
||||
: (MV_CLASS_TYPE)log_in_base_2(z >> 3);
|
||||
if (offset) *offset = z - mv_class_base(c);
|
||||
return c;
|
||||
}
|
||||
|
||||
static void encode_mv_component(aom_writer *w, int comp, nmv_component *mvcomp,
|
||||
MvSubpelPrecision precision) {
|
||||
assert(comp != 0);
|
||||
int offset;
|
||||
const int sign = comp < 0;
|
||||
const int mag = sign ? -comp : comp;
|
||||
const int mv_class = av1_get_mv_class(mag - 1, &offset);
|
||||
const int mv_class = get_mv_class(mag - 1, &offset);
|
||||
const int d = offset >> 3; // int mv data
|
||||
const int fr = (offset >> 1) & 3; // fractional mv data
|
||||
const int hp = offset & 1; // high precision mv data
|
||||
|
||||
assert(comp != 0);
|
||||
|
||||
// Sign
|
||||
aom_write_symbol(w, sign, mvcomp->sign_cdf, 2);
|
||||
|
||||
|
|
@ -89,7 +107,7 @@ static void build_nmv_component_cost_table(int *mvcost,
|
|||
for (v = 1; v <= MV_MAX; ++v) {
|
||||
int z, c, o, d, e, f, cost = 0;
|
||||
z = v - 1;
|
||||
c = av1_get_mv_class(z, &o);
|
||||
c = get_mv_class(z, &o);
|
||||
cost += class_cost[c];
|
||||
d = (o >> 3); /* int mv data */
|
||||
f = (o >> 1) & 3; /* fractional pel mv data */
|
||||
|
|
|
|||
14
third_party/aom/av1/encoder/encodemv.h
vendored
14
third_party/aom/av1/encoder/encodemv.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_ENCODEMV_H_
|
||||
#define AV1_ENCODER_ENCODEMV_H_
|
||||
#ifndef AOM_AV1_ENCODER_ENCODEMV_H_
|
||||
#define AOM_AV1_ENCODER_ENCODEMV_H_
|
||||
|
||||
#include "av1/encoder/encoder.h"
|
||||
|
||||
|
|
@ -40,8 +40,16 @@ void av1_find_best_ref_mvs_from_stack(int allow_hp,
|
|||
int_mv *nearest_mv, int_mv *near_mv,
|
||||
int is_integer);
|
||||
|
||||
static INLINE MV_JOINT_TYPE av1_get_mv_joint(const MV *mv) {
|
||||
if (mv->row == 0) {
|
||||
return mv->col == 0 ? MV_JOINT_ZERO : MV_JOINT_HNZVZ;
|
||||
} else {
|
||||
return mv->col == 0 ? MV_JOINT_HZVNZ : MV_JOINT_HNZVNZ;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_ENCODEMV_H_
|
||||
#endif // AOM_AV1_ENCODER_ENCODEMV_H_
|
||||
|
|
|
|||
490
third_party/aom/av1/encoder/encoder.c
vendored
490
third_party/aom/av1/encoder/encoder.c
vendored
|
|
@ -14,9 +14,28 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "config/aom_config.h"
|
||||
#include "config/av1_rtcd.h"
|
||||
#include "config/aom_dsp_rtcd.h"
|
||||
#include "config/aom_scale_rtcd.h"
|
||||
#include "config/av1_rtcd.h"
|
||||
|
||||
#include "aom_dsp/aom_dsp_common.h"
|
||||
#include "aom_dsp/aom_filter.h"
|
||||
#if CONFIG_DENOISE
|
||||
#include "aom_dsp/grain_table.h"
|
||||
#include "aom_dsp/noise_util.h"
|
||||
#include "aom_dsp/noise_model.h"
|
||||
#endif
|
||||
#include "aom_dsp/psnr.h"
|
||||
#if CONFIG_INTERNAL_STATS
|
||||
#include "aom_dsp/ssim.h"
|
||||
#endif
|
||||
#include "aom_ports/aom_timer.h"
|
||||
#include "aom_ports/mem.h"
|
||||
#include "aom_ports/system_state.h"
|
||||
#include "aom_scale/aom_scale.h"
|
||||
#if CONFIG_BITSTREAM_DEBUG || CONFIG_MISMATCH_DEBUG
|
||||
#include "aom_util/debug_util.h"
|
||||
#endif // CONFIG_BITSTREAM_DEBUG || CONFIG_MISMATCH_DEBUG
|
||||
|
||||
#include "av1/common/alloccommon.h"
|
||||
#include "av1/common/cdef.h"
|
||||
|
|
@ -38,6 +57,7 @@
|
|||
#include "av1/encoder/encodetxb.h"
|
||||
#include "av1/encoder/ethread.h"
|
||||
#include "av1/encoder/firstpass.h"
|
||||
#include "av1/encoder/grain_test_vectors.h"
|
||||
#include "av1/encoder/hash_motion.h"
|
||||
#include "av1/encoder/mbgraph.h"
|
||||
#include "av1/encoder/picklpf.h"
|
||||
|
|
@ -49,26 +69,6 @@
|
|||
#include "av1/encoder/speed_features.h"
|
||||
#include "av1/encoder/temporal_filter.h"
|
||||
|
||||
#include "aom_dsp/psnr.h"
|
||||
#if CONFIG_INTERNAL_STATS
|
||||
#include "aom_dsp/ssim.h"
|
||||
#endif
|
||||
#include "av1/encoder/grain_test_vectors.h"
|
||||
#include "aom_dsp/aom_dsp_common.h"
|
||||
#include "aom_dsp/aom_filter.h"
|
||||
#if CONFIG_DENOISE
|
||||
#include "aom_dsp/grain_table.h"
|
||||
#include "aom_dsp/noise_util.h"
|
||||
#include "aom_dsp/noise_model.h"
|
||||
#endif
|
||||
#include "aom_ports/aom_timer.h"
|
||||
#include "aom_ports/mem.h"
|
||||
#include "aom_ports/system_state.h"
|
||||
#include "aom_scale/aom_scale.h"
|
||||
#if CONFIG_BITSTREAM_DEBUG || CONFIG_MISMATCH_DEBUG
|
||||
#include "aom_util/debug_util.h"
|
||||
#endif // CONFIG_BITSTREAM_DEBUG || CONFIG_MISMATCH_DEBUG
|
||||
|
||||
#define DEFAULT_EXPLICIT_ORDER_HINT_BITS 7
|
||||
|
||||
// av1 uses 10,000,000 ticks/second as time stamp
|
||||
|
|
@ -413,18 +413,13 @@ static void swap_mi_and_prev_mi(AV1_COMMON *cm) {
|
|||
}
|
||||
|
||||
void av1_initialize_enc(void) {
|
||||
static volatile int init_done = 0;
|
||||
|
||||
if (!init_done) {
|
||||
av1_rtcd();
|
||||
aom_dsp_rtcd();
|
||||
aom_scale_rtcd();
|
||||
av1_init_intra_predictors();
|
||||
av1_init_me_luts();
|
||||
av1_rc_init_minq_luts();
|
||||
av1_init_wedge_masks();
|
||||
init_done = 1;
|
||||
}
|
||||
av1_rtcd();
|
||||
aom_dsp_rtcd();
|
||||
aom_scale_rtcd();
|
||||
av1_init_intra_predictors();
|
||||
av1_init_me_luts();
|
||||
av1_rc_init_minq_luts();
|
||||
av1_init_wedge_masks();
|
||||
}
|
||||
|
||||
static void dealloc_context_buffers_ext(AV1_COMP *cpi) {
|
||||
|
|
@ -506,6 +501,11 @@ static void dealloc_compressor_data(AV1_COMP *cpi) {
|
|||
aom_free(cpi->td.mb.wsrc_buf);
|
||||
cpi->td.mb.wsrc_buf = NULL;
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int j = 0; j < 2; j++) {
|
||||
aom_free(cpi->td.mb.hash_value_buffer[i][j]);
|
||||
cpi->td.mb.hash_value_buffer[i][j] = NULL;
|
||||
}
|
||||
aom_free(cpi->td.mb.mask_buf);
|
||||
cpi->td.mb.mask_buf = NULL;
|
||||
|
||||
|
|
@ -527,10 +527,18 @@ static void dealloc_compressor_data(AV1_COMP *cpi) {
|
|||
aom_free(cpi->tile_tok[0][0]);
|
||||
cpi->tile_tok[0][0] = 0;
|
||||
|
||||
aom_free(cpi->tplist[0][0]);
|
||||
cpi->tplist[0][0] = NULL;
|
||||
|
||||
av1_free_pc_tree(&cpi->td, num_planes);
|
||||
|
||||
aom_free(cpi->td.mb.palette_buffer);
|
||||
|
||||
aom_free(cpi->td.mb.tmp_conv_dst);
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
aom_free(cpi->td.mb.tmp_obmc_bufs[j]);
|
||||
}
|
||||
|
||||
#if CONFIG_DENOISE
|
||||
if (cpi->denoise_and_model) {
|
||||
aom_denoise_and_model_free(cpi->denoise_and_model);
|
||||
|
|
@ -785,6 +793,10 @@ static void alloc_compressor_data(AV1_COMP *cpi) {
|
|||
|
||||
av1_alloc_context_buffers(cm, cm->width, cm->height);
|
||||
|
||||
int mi_rows_aligned_to_sb =
|
||||
ALIGN_POWER_OF_TWO(cm->mi_rows, cm->seq_params.mib_size_log2);
|
||||
int sb_rows = mi_rows_aligned_to_sb >> cm->seq_params.mib_size_log2;
|
||||
|
||||
av1_alloc_txb_buf(cpi);
|
||||
|
||||
alloc_context_buffers_ext(cpi);
|
||||
|
|
@ -797,6 +809,11 @@ static void alloc_compressor_data(AV1_COMP *cpi) {
|
|||
CHECK_MEM_ERROR(cm, cpi->tile_tok[0][0],
|
||||
aom_calloc(tokens, sizeof(*cpi->tile_tok[0][0])));
|
||||
}
|
||||
aom_free(cpi->tplist[0][0]);
|
||||
|
||||
CHECK_MEM_ERROR(cm, cpi->tplist[0][0],
|
||||
aom_calloc(sb_rows * MAX_TILE_ROWS * MAX_TILE_COLS,
|
||||
sizeof(*cpi->tplist[0][0])));
|
||||
|
||||
av1_setup_pc_tree(&cpi->common, &cpi->td);
|
||||
}
|
||||
|
|
@ -1067,6 +1084,32 @@ static void init_config(struct AV1_COMP *cpi, AV1EncoderConfig *oxcf) {
|
|||
10; // Default value (not signaled)
|
||||
}
|
||||
|
||||
if (cm->seq_params.monochrome) {
|
||||
cm->seq_params.subsampling_x = 1;
|
||||
cm->seq_params.subsampling_y = 1;
|
||||
} else if (cm->seq_params.color_primaries == AOM_CICP_CP_BT_709 &&
|
||||
cm->seq_params.transfer_characteristics == AOM_CICP_TC_SRGB &&
|
||||
cm->seq_params.matrix_coefficients == AOM_CICP_MC_IDENTITY) {
|
||||
cm->seq_params.subsampling_x = 0;
|
||||
cm->seq_params.subsampling_y = 0;
|
||||
} else {
|
||||
if (cm->seq_params.profile == 0) {
|
||||
cm->seq_params.subsampling_x = 1;
|
||||
cm->seq_params.subsampling_y = 1;
|
||||
} else if (cm->seq_params.profile == 1) {
|
||||
cm->seq_params.subsampling_x = 0;
|
||||
cm->seq_params.subsampling_y = 0;
|
||||
} else {
|
||||
if (cm->seq_params.bit_depth == AOM_BITS_12) {
|
||||
cm->seq_params.subsampling_x = oxcf->chroma_subsampling_x;
|
||||
cm->seq_params.subsampling_y = oxcf->chroma_subsampling_y;
|
||||
} else {
|
||||
cm->seq_params.subsampling_x = 1;
|
||||
cm->seq_params.subsampling_y = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cm->width = oxcf->width;
|
||||
cm->height = oxcf->height;
|
||||
set_sb_size(&cm->seq_params,
|
||||
|
|
@ -2326,6 +2369,7 @@ void av1_change_config(struct AV1_COMP *cpi, const AV1EncoderConfig *oxcf) {
|
|||
|
||||
cpi->oxcf = *oxcf;
|
||||
cpi->common.options = oxcf->cfg;
|
||||
cpi->row_mt = oxcf->row_mt;
|
||||
x->e_mbd.bd = (int)seq_params->bit_depth;
|
||||
x->e_mbd.global_motion = cm->global_motion;
|
||||
|
||||
|
|
@ -2350,6 +2394,22 @@ void av1_change_config(struct AV1_COMP *cpi, const AV1EncoderConfig *oxcf) {
|
|||
CHECK_MEM_ERROR(cm, x->palette_buffer,
|
||||
aom_memalign(16, sizeof(*x->palette_buffer)));
|
||||
}
|
||||
|
||||
if (x->tmp_conv_dst == NULL) {
|
||||
CHECK_MEM_ERROR(
|
||||
cm, x->tmp_conv_dst,
|
||||
aom_memalign(32, MAX_SB_SIZE * MAX_SB_SIZE * sizeof(*x->tmp_conv_dst)));
|
||||
x->e_mbd.tmp_conv_dst = x->tmp_conv_dst;
|
||||
}
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if (x->tmp_obmc_bufs[i] == NULL) {
|
||||
CHECK_MEM_ERROR(cm, x->tmp_obmc_bufs[i],
|
||||
aom_memalign(16, 2 * MAX_MB_PLANE * MAX_SB_SQUARE *
|
||||
sizeof(*x->tmp_obmc_bufs[i])));
|
||||
x->e_mbd.tmp_obmc_bufs[i] = x->tmp_obmc_bufs[i];
|
||||
}
|
||||
}
|
||||
|
||||
av1_reset_segment_features(cm);
|
||||
set_high_precision_mv(cpi, 1, 0);
|
||||
|
||||
|
|
@ -2367,11 +2427,7 @@ void av1_change_config(struct AV1_COMP *cpi, const AV1EncoderConfig *oxcf) {
|
|||
rc->worst_quality = cpi->oxcf.worst_allowed_q;
|
||||
rc->best_quality = cpi->oxcf.best_allowed_q;
|
||||
|
||||
if (!oxcf->large_scale_tile)
|
||||
cm->interp_filter = cpi->sf.default_interp_filter;
|
||||
else
|
||||
cm->interp_filter = EIGHTTAP_REGULAR;
|
||||
|
||||
cm->interp_filter = oxcf->large_scale_tile ? EIGHTTAP_REGULAR : SWITCHABLE;
|
||||
cm->switchable_motion_mode = 1;
|
||||
|
||||
if (cpi->oxcf.render_width > 0 && cpi->oxcf.render_height > 0) {
|
||||
|
|
@ -2588,6 +2644,15 @@ AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
|
|||
(int32_t *)aom_memalign(
|
||||
16, MAX_SB_SQUARE * sizeof(*cpi->td.mb.wsrc_buf)));
|
||||
|
||||
for (int x = 0; x < 2; x++)
|
||||
for (int y = 0; y < 2; y++)
|
||||
CHECK_MEM_ERROR(
|
||||
cm, cpi->td.mb.hash_value_buffer[x][y],
|
||||
(uint32_t *)aom_malloc(AOM_BUFFER_SIZE_FOR_BLOCK_HASH *
|
||||
sizeof(*cpi->td.mb.hash_value_buffer[0][0])));
|
||||
|
||||
cpi->td.mb.g_crc_initialized = 0;
|
||||
|
||||
CHECK_MEM_ERROR(cm, cpi->td.mb.mask_buf,
|
||||
(int32_t *)aom_memalign(
|
||||
16, MAX_SB_SQUARE * sizeof(*cpi->td.mb.mask_buf)));
|
||||
|
|
@ -2913,9 +2978,19 @@ void av1_remove_compressor(AV1_COMP *cpi) {
|
|||
// Deallocate allocated thread data.
|
||||
if (t < cpi->num_workers - 1) {
|
||||
aom_free(thread_data->td->palette_buffer);
|
||||
aom_free(thread_data->td->tmp_conv_dst);
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
aom_free(thread_data->td->tmp_obmc_bufs[j]);
|
||||
}
|
||||
aom_free(thread_data->td->above_pred_buf);
|
||||
aom_free(thread_data->td->left_pred_buf);
|
||||
aom_free(thread_data->td->wsrc_buf);
|
||||
for (int x = 0; x < 2; x++) {
|
||||
for (int y = 0; y < 2; y++) {
|
||||
aom_free(thread_data->td->hash_value_buffer[x][y]);
|
||||
thread_data->td->hash_value_buffer[x][y] = NULL;
|
||||
}
|
||||
}
|
||||
aom_free(thread_data->td->mask_buf);
|
||||
aom_free(thread_data->td->counts);
|
||||
av1_free_pc_tree(thread_data->td, num_planes);
|
||||
|
|
@ -3058,53 +3133,7 @@ void aom_write_yuv_frame_420(YV12_BUFFER_CONFIG *s, FILE *f) {
|
|||
}
|
||||
#endif
|
||||
|
||||
#if USE_GF16_MULTI_LAYER
|
||||
static void check_show_existing_frame_gf16(AV1_COMP *cpi) {
|
||||
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
const FRAME_UPDATE_TYPE next_frame_update_type =
|
||||
gf_group->update_type[gf_group->index];
|
||||
|
||||
if (cm->show_existing_frame == 1) {
|
||||
cm->show_existing_frame = 0;
|
||||
} else if (cpi->rc.is_last_bipred_frame) {
|
||||
cpi->rc.is_last_bipred_frame = 0;
|
||||
cm->show_existing_frame = 1;
|
||||
cpi->existing_fb_idx_to_show = cpi->ref_fb_idx[BWDREF_FRAME - 1];
|
||||
} else if (next_frame_update_type == OVERLAY_UPDATE ||
|
||||
next_frame_update_type == INTNL_OVERLAY_UPDATE) {
|
||||
// Check the temporal filtering status for the next OVERLAY frame
|
||||
const int num_arfs_in_gf = cpi->num_extra_arfs + 1;
|
||||
int which_arf = 0, arf_idx;
|
||||
// Identify the index to the next overlay frame.
|
||||
for (arf_idx = 0; arf_idx < num_arfs_in_gf; arf_idx++) {
|
||||
if (gf_group->index == cpi->arf_pos_for_ovrly[arf_idx]) {
|
||||
which_arf = arf_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(arf_idx < num_arfs_in_gf);
|
||||
if (cpi->is_arf_filter_off[which_arf]) {
|
||||
cm->show_existing_frame = 1;
|
||||
cpi->rc.is_src_frame_alt_ref = 1;
|
||||
cpi->existing_fb_idx_to_show = (next_frame_update_type == OVERLAY_UPDATE)
|
||||
? cpi->ref_fb_idx[ALTREF_FRAME - 1]
|
||||
: cpi->ref_fb_idx[BWDREF_FRAME - 1];
|
||||
cpi->is_arf_filter_off[which_arf] = 0;
|
||||
}
|
||||
}
|
||||
cpi->rc.is_src_frame_ext_arf = 0;
|
||||
}
|
||||
#endif // USE_GF16_MULTI_LAYER
|
||||
|
||||
static void check_show_existing_frame(AV1_COMP *cpi) {
|
||||
#if USE_GF16_MULTI_LAYER
|
||||
if (cpi->rc.baseline_gf_interval == 16) {
|
||||
check_show_existing_frame_gf16(cpi);
|
||||
return;
|
||||
}
|
||||
#endif // USE_GF16_MULTI_LAYER
|
||||
|
||||
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
const FRAME_UPDATE_TYPE next_frame_update_type =
|
||||
|
|
@ -3350,13 +3379,13 @@ static INLINE void rshift_bwd_ref_frames(AV1_COMP *cpi) {
|
|||
EXTREF_FRAME - 1 };
|
||||
|
||||
for (int i = 2; i > 0; --i) {
|
||||
cpi->ref_fb_idx[ordered_bwd[i]] = cpi->ref_fb_idx[ordered_bwd[i - 1]];
|
||||
|
||||
// [0] is allocated to the current coded frame, i.e. bwdref
|
||||
memcpy(
|
||||
cpi->interp_filter_selected[ordered_bwd[i] + LAST_FRAME],
|
||||
cpi->interp_filter_selected[ordered_bwd[i - 1] + LAST_FRAME],
|
||||
sizeof(cpi->interp_filter_selected[ordered_bwd[i - 1] + LAST_FRAME]));
|
||||
|
||||
cpi->ref_fb_idx[ordered_bwd[i]] = cpi->ref_fb_idx[ordered_bwd[i - 1]];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3370,53 +3399,17 @@ static INLINE void lshift_bwd_ref_frames(AV1_COMP *cpi) {
|
|||
EXTREF_FRAME - 1 };
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
cpi->ref_fb_idx[ordered_bwd[i]] = cpi->ref_fb_idx[ordered_bwd[i + 1]];
|
||||
|
||||
// [0] is allocated to the current coded frame, i.e. bwdref
|
||||
memcpy(
|
||||
cpi->interp_filter_selected[ordered_bwd[i] + LAST_FRAME],
|
||||
cpi->interp_filter_selected[ordered_bwd[i + 1] + LAST_FRAME],
|
||||
sizeof(cpi->interp_filter_selected[ordered_bwd[i + 1] + LAST_FRAME]));
|
||||
|
||||
cpi->ref_fb_idx[ordered_bwd[i]] = cpi->ref_fb_idx[ordered_bwd[i + 1]];
|
||||
}
|
||||
}
|
||||
#endif // USE_SYMM_MULTI_LAYER
|
||||
|
||||
#if USE_GF16_MULTI_LAYER
|
||||
static void update_reference_frames_gf16(AV1_COMP *cpi) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
BufferPool *const pool = cm->buffer_pool;
|
||||
|
||||
if (cm->frame_type == KEY_FRAME) {
|
||||
for (int ref_frame = 0; ref_frame < REF_FRAMES; ++ref_frame) {
|
||||
ref_cnt_fb(pool->frame_bufs,
|
||||
&cm->ref_frame_map[cpi->ref_fb_idx[ref_frame]],
|
||||
cm->new_fb_idx);
|
||||
}
|
||||
} else {
|
||||
if (cpi->refresh_last_frame || cpi->refresh_golden_frame ||
|
||||
cpi->refresh_bwd_ref_frame || cpi->refresh_alt2_ref_frame ||
|
||||
cpi->refresh_alt_ref_frame) {
|
||||
assert(cpi->refresh_fb_idx >= 0 && cpi->refresh_fb_idx < REF_FRAMES);
|
||||
ref_cnt_fb(pool->frame_bufs, &cm->ref_frame_map[cpi->refresh_fb_idx],
|
||||
cm->new_fb_idx);
|
||||
}
|
||||
|
||||
// TODO(zoeliu): To handle cpi->interp_filter_selected[].
|
||||
|
||||
// For GF of 16, an additional ref frame index mapping needs to be handled
|
||||
// if this is the last frame to encode in the current GF group.
|
||||
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
|
||||
if (gf_group->update_type[gf_group->index + 1] == OVERLAY_UPDATE)
|
||||
av1_ref_frame_map_idx_updates(cpi, gf_group->index + 1);
|
||||
}
|
||||
|
||||
#if DUMP_REF_FRAME_IMAGES == 1
|
||||
// Dump out all reference frame images.
|
||||
dump_ref_frame_images(cpi);
|
||||
#endif // DUMP_REF_FRAME_IMAGES
|
||||
}
|
||||
#endif // USE_GF16_MULTI_LAYER
|
||||
|
||||
static void update_reference_frames(AV1_COMP *cpi) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
|
||||
|
|
@ -3424,12 +3417,20 @@ static void update_reference_frames(AV1_COMP *cpi) {
|
|||
// for the purpose to verify no mismatch between encoder and decoder.
|
||||
if (cm->show_frame) cpi->last_show_frame_buf_idx = cm->new_fb_idx;
|
||||
|
||||
#if USE_GF16_MULTI_LAYER
|
||||
if (cpi->rc.baseline_gf_interval == 16) {
|
||||
update_reference_frames_gf16(cpi);
|
||||
return;
|
||||
// In the case of show_existing frame, we will not send fresh flag
|
||||
// to decoder. Any change in the reference frame buffer can be done by
|
||||
// switching the virtual indices.
|
||||
if (cm->show_existing_frame) {
|
||||
cpi->refresh_last_frame = 0;
|
||||
cpi->refresh_golden_frame = 0;
|
||||
cpi->refresh_bwd_ref_frame = 0;
|
||||
cpi->refresh_alt2_ref_frame = 0;
|
||||
cpi->refresh_alt_ref_frame = 0;
|
||||
|
||||
cpi->rc.is_bwd_ref_frame = 0;
|
||||
cpi->rc.is_last_bipred_frame = 0;
|
||||
cpi->rc.is_bipred_frame = 0;
|
||||
}
|
||||
#endif // USE_GF16_MULTI_LAYER
|
||||
|
||||
BufferPool *const pool = cm->buffer_pool;
|
||||
|
||||
|
|
@ -3458,9 +3459,15 @@ static void update_reference_frames(AV1_COMP *cpi) {
|
|||
// slot and, if we're updating the GF, the current frame becomes the new GF.
|
||||
int tmp;
|
||||
|
||||
ref_cnt_fb(pool->frame_bufs,
|
||||
&cm->ref_frame_map[cpi->ref_fb_idx[ALTREF_FRAME - 1]],
|
||||
cm->new_fb_idx);
|
||||
// ARF in general is a better reference than overlay. We shouldkeep ARF as
|
||||
// reference instead of replacing it with overlay.
|
||||
|
||||
if (!cpi->preserve_arf_as_gld) {
|
||||
ref_cnt_fb(pool->frame_bufs,
|
||||
&cm->ref_frame_map[cpi->ref_fb_idx[ALTREF_FRAME - 1]],
|
||||
cm->new_fb_idx);
|
||||
}
|
||||
|
||||
tmp = cpi->ref_fb_idx[ALTREF_FRAME - 1];
|
||||
cpi->ref_fb_idx[ALTREF_FRAME - 1] = cpi->ref_fb_idx[GOLDEN_FRAME - 1];
|
||||
cpi->ref_fb_idx[GOLDEN_FRAME - 1] = tmp;
|
||||
|
|
@ -3758,7 +3765,7 @@ static void set_size_independent_vars(AV1_COMP *cpi) {
|
|||
av1_set_speed_features_framesize_independent(cpi);
|
||||
av1_set_rd_speed_thresholds(cpi);
|
||||
av1_set_rd_speed_thresholds_sub8x8(cpi);
|
||||
cpi->common.interp_filter = cpi->sf.default_interp_filter;
|
||||
cpi->common.interp_filter = SWITCHABLE;
|
||||
cpi->common.switchable_motion_mode = 1;
|
||||
}
|
||||
|
||||
|
|
@ -3818,7 +3825,8 @@ static void set_restoration_unit_size(int width, int height, int sx, int sy,
|
|||
rst[2].restoration_unit_size = rst[1].restoration_unit_size;
|
||||
}
|
||||
|
||||
static void init_ref_frame_bufs(AV1_COMMON *cm) {
|
||||
static void init_ref_frame_bufs(AV1_COMP *cpi) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
int i;
|
||||
BufferPool *const pool = cm->buffer_pool;
|
||||
cm->new_fb_idx = INVALID_IDX;
|
||||
|
|
@ -3828,7 +3836,7 @@ static void init_ref_frame_bufs(AV1_COMMON *cm) {
|
|||
}
|
||||
if (cm->seq_params.force_screen_content_tools) {
|
||||
for (i = 0; i < FRAME_BUFFERS; ++i) {
|
||||
av1_hash_table_init(&pool->frame_bufs[i].hash_table);
|
||||
av1_hash_table_init(&pool->frame_bufs[i].hash_table, &cpi->td.mb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3846,7 +3854,7 @@ static void check_initial_width(AV1_COMP *cpi, int use_highbitdepth,
|
|||
seq_params->use_highbitdepth = use_highbitdepth;
|
||||
|
||||
alloc_raw_frame_buffers(cpi);
|
||||
init_ref_frame_bufs(cm);
|
||||
init_ref_frame_bufs(cpi);
|
||||
alloc_util_frame_buffers(cpi);
|
||||
|
||||
init_motion_estimation(cpi); // TODO(agrange) This can be removed.
|
||||
|
|
@ -4220,7 +4228,7 @@ static void loopfilter_frame(AV1_COMP *cpi, AV1_COMMON *cm) {
|
|||
|
||||
if (lf->filter_level[0] || lf->filter_level[1]) {
|
||||
#if LOOP_FILTER_BITMASK
|
||||
av1_loop_filter_frame(cm->frame_to_show, cm, xd, 0, num_planes, 0);
|
||||
av1_loop_filter_frame(cm->frame_to_show, cm, xd, 0, 0, num_planes, 0);
|
||||
#else
|
||||
if (cpi->num_workers > 1)
|
||||
av1_loop_filter_frame_mt(cm->frame_to_show, cm, xd, 0, num_planes, 0,
|
||||
|
|
@ -4587,8 +4595,8 @@ static int encode_with_recode_loop(AV1_COMP *cpi, size_t *size, uint8_t *dest) {
|
|||
rc->projected_frame_size < rc->max_frame_bandwidth)
|
||||
loop = 0;
|
||||
|
||||
if (recode_loop_test_global_motion(cpi)) {
|
||||
loop = 1;
|
||||
if (!cpi->sf.gm_disable_recode) {
|
||||
if (recode_loop_test_global_motion(cpi)) loop = 1;
|
||||
}
|
||||
|
||||
if (loop) {
|
||||
|
|
@ -4716,47 +4724,6 @@ static void set_ext_overrides(AV1_COMP *cpi) {
|
|||
cpi->ext_use_error_resilient && cpi->common.frame_type != KEY_FRAME;
|
||||
}
|
||||
|
||||
static int setup_interp_filter_search_mask(AV1_COMP *cpi) {
|
||||
InterpFilter ifilter;
|
||||
int ref_total[REF_FRAMES] = { 0 };
|
||||
MV_REFERENCE_FRAME ref;
|
||||
int mask = 0;
|
||||
int arf_idx = ALTREF_FRAME;
|
||||
|
||||
if (cpi->common.last_frame_type == KEY_FRAME || cpi->refresh_alt_ref_frame ||
|
||||
cpi->refresh_alt2_ref_frame)
|
||||
return mask;
|
||||
|
||||
for (ref = LAST_FRAME; ref <= ALTREF_FRAME; ++ref)
|
||||
for (ifilter = EIGHTTAP_REGULAR; ifilter < SWITCHABLE_FILTERS; ++ifilter)
|
||||
ref_total[ref] += cpi->interp_filter_selected[ref][ifilter];
|
||||
|
||||
for (ifilter = EIGHTTAP_REGULAR; ifilter < SWITCHABLE_FILTERS; ++ifilter) {
|
||||
if ((ref_total[LAST_FRAME] &&
|
||||
cpi->interp_filter_selected[LAST_FRAME][ifilter] == 0) &&
|
||||
(ref_total[LAST2_FRAME] == 0 ||
|
||||
cpi->interp_filter_selected[LAST2_FRAME][ifilter] * 50 <
|
||||
ref_total[LAST2_FRAME]) &&
|
||||
(ref_total[LAST3_FRAME] == 0 ||
|
||||
cpi->interp_filter_selected[LAST3_FRAME][ifilter] * 50 <
|
||||
ref_total[LAST3_FRAME]) &&
|
||||
(ref_total[GOLDEN_FRAME] == 0 ||
|
||||
cpi->interp_filter_selected[GOLDEN_FRAME][ifilter] * 50 <
|
||||
ref_total[GOLDEN_FRAME]) &&
|
||||
(ref_total[BWDREF_FRAME] == 0 ||
|
||||
cpi->interp_filter_selected[BWDREF_FRAME][ifilter] * 50 <
|
||||
ref_total[BWDREF_FRAME]) &&
|
||||
(ref_total[ALTREF2_FRAME] == 0 ||
|
||||
cpi->interp_filter_selected[ALTREF2_FRAME][ifilter] * 50 <
|
||||
ref_total[ALTREF2_FRAME]) &&
|
||||
(ref_total[ALTREF_FRAME] == 0 ||
|
||||
cpi->interp_filter_selected[arf_idx][ifilter] * 50 <
|
||||
ref_total[ALTREF_FRAME]))
|
||||
mask |= 1 << ifilter;
|
||||
}
|
||||
return mask;
|
||||
}
|
||||
|
||||
#define DUMP_RECON_FRAMES 0
|
||||
|
||||
#if DUMP_RECON_FRAMES == 1
|
||||
|
|
@ -4914,7 +4881,7 @@ static int encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size, uint8_t *dest,
|
|||
if (cm->current_video_frame > 0)
|
||||
cpi->ref_frame_flags = get_ref_frame_flags(cpi);
|
||||
|
||||
if (cm->show_existing_frame) {
|
||||
if (encode_show_existing_frame(cm)) {
|
||||
// NOTE(zoeliu): In BIDIR_PRED, the existing frame to show is the current
|
||||
// BWDREF_FRAME in the reference frame buffer.
|
||||
if (cm->frame_type == KEY_FRAME) {
|
||||
|
|
@ -4925,20 +4892,6 @@ static int encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size, uint8_t *dest,
|
|||
cm->show_frame = 1;
|
||||
cpi->frame_flags = *frame_flags;
|
||||
|
||||
// In the case of show_existing frame, we will not send fresh flag
|
||||
// to decoder. Any change in the reference frame buffer can be done by
|
||||
// switching the virtual indices.
|
||||
|
||||
cpi->refresh_last_frame = 0;
|
||||
cpi->refresh_golden_frame = 0;
|
||||
cpi->refresh_bwd_ref_frame = 0;
|
||||
cpi->refresh_alt2_ref_frame = 0;
|
||||
cpi->refresh_alt_ref_frame = 0;
|
||||
|
||||
cpi->rc.is_bwd_ref_frame = 0;
|
||||
cpi->rc.is_last_bipred_frame = 0;
|
||||
cpi->rc.is_bipred_frame = 0;
|
||||
|
||||
restore_coding_context(cpi);
|
||||
|
||||
// Build the bitstream
|
||||
|
|
@ -4990,10 +4943,6 @@ static int encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size, uint8_t *dest,
|
|||
av1_rc_postencode_update(cpi, *size);
|
||||
}
|
||||
|
||||
// Decrement count down till next gf
|
||||
if (cpi->rc.frames_till_gf_update_due > 0)
|
||||
cpi->rc.frames_till_gf_update_due--;
|
||||
|
||||
++cm->current_video_frame;
|
||||
|
||||
return AOM_CODEC_OK;
|
||||
|
|
@ -5002,9 +4951,6 @@ static int encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size, uint8_t *dest,
|
|||
// Set default state for segment based loop filter update flags.
|
||||
cm->lf.mode_ref_delta_update = 0;
|
||||
|
||||
if (cpi->oxcf.pass == 2 && cpi->sf.adaptive_interp_filter_search)
|
||||
cpi->sf.interp_filter_search_mask = setup_interp_filter_search_mask(cpi);
|
||||
|
||||
// Set various flags etc to special state if it is a key frame.
|
||||
if (frame_is_intra_only(cm) || frame_is_sframe(cm)) {
|
||||
// Reset the loop filter deltas and segmentation map.
|
||||
|
|
@ -5246,15 +5192,6 @@ static int encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size, uint8_t *dest,
|
|||
// takes a space in the gf group. Therefore, even when
|
||||
// it is not shown, we still need update the count down.
|
||||
|
||||
// TODO(weitinglin): This is a work-around to handle the condition
|
||||
// when a frame is drop. We should fix the cm->show_frame flag
|
||||
// instead of checking the other condition to update the counter properly.
|
||||
if (cm->show_frame || is_frame_droppable(cpi)) {
|
||||
// Decrement count down till next gf
|
||||
if (cpi->rc.frames_till_gf_update_due > 0)
|
||||
cpi->rc.frames_till_gf_update_due--;
|
||||
}
|
||||
|
||||
if (cm->show_frame) {
|
||||
// TODO(zoeliu): We may only swamp mi and prev_mi for those frames that
|
||||
// are
|
||||
|
|
@ -5279,6 +5216,50 @@ static int encode_frame_to_data_rate(AV1_COMP *cpi, size_t *size, uint8_t *dest,
|
|||
return AOM_CODEC_OK;
|
||||
}
|
||||
|
||||
static INLINE void update_keyframe_counters(AV1_COMP *cpi) {
|
||||
// TODO(zoeliu): To investigate whether we should treat BWDREF_FRAME
|
||||
// differently here for rc->avg_frame_bandwidth.
|
||||
if (cpi->common.show_frame || cpi->rc.is_bwd_ref_frame) {
|
||||
if (!cpi->common.show_existing_frame || cpi->rc.is_src_frame_alt_ref ||
|
||||
cpi->common.frame_type == KEY_FRAME) {
|
||||
// If this is a show_existing_frame with a source other than altref,
|
||||
// or if it is not a displayed forward keyframe, the keyframe update
|
||||
// counters were incremented when it was originally encoded.
|
||||
cpi->rc.frames_since_key++;
|
||||
cpi->rc.frames_to_key--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void update_frames_till_gf_update(AV1_COMP *cpi) {
|
||||
// TODO(weitinglin): Updating this counter for is_frame_droppable
|
||||
// is a work-around to handle the condition when a frame is drop.
|
||||
// We should fix the cpi->common.show_frame flag
|
||||
// instead of checking the other condition to update the counter properly.
|
||||
if (cpi->common.show_frame || is_frame_droppable(cpi)) {
|
||||
// Decrement count down till next gf
|
||||
if (cpi->rc.frames_till_gf_update_due > 0)
|
||||
cpi->rc.frames_till_gf_update_due--;
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void update_twopass_gf_group_index(AV1_COMP *cpi) {
|
||||
// Increment the gf group index ready for the next frame. If this is
|
||||
// a show_existing_frame with a source other than altref, or if it is not
|
||||
// a displayed forward keyframe, the index was incremented when it was
|
||||
// originally encoded.
|
||||
if (!cpi->common.show_existing_frame || cpi->rc.is_src_frame_alt_ref ||
|
||||
cpi->common.frame_type == KEY_FRAME) {
|
||||
++cpi->twopass.gf_group.index;
|
||||
}
|
||||
}
|
||||
|
||||
static void update_rc_counts(AV1_COMP *cpi) {
|
||||
update_keyframe_counters(cpi);
|
||||
update_frames_till_gf_update(cpi);
|
||||
if (cpi->oxcf.pass == 2) update_twopass_gf_group_index(cpi);
|
||||
}
|
||||
|
||||
static int Pass0Encode(AV1_COMP *cpi, size_t *size, uint8_t *dest,
|
||||
int skip_adapt, unsigned int *frame_flags) {
|
||||
if (cpi->oxcf.rc_mode == AOM_CBR) {
|
||||
|
|
@ -5290,6 +5271,7 @@ static int Pass0Encode(AV1_COMP *cpi, size_t *size, uint8_t *dest,
|
|||
AOM_CODEC_OK) {
|
||||
return AOM_CODEC_ERROR;
|
||||
}
|
||||
update_rc_counts(cpi);
|
||||
check_show_existing_frame(cpi);
|
||||
return AOM_CODEC_OK;
|
||||
}
|
||||
|
|
@ -5319,14 +5301,8 @@ static int Pass2Encode(AV1_COMP *cpi, size_t *size, uint8_t *dest,
|
|||
cm->cum_txcoeff_cost_timer);
|
||||
#endif
|
||||
|
||||
// Do not do post-encoding update for those frames that do not have a spot
|
||||
// in
|
||||
// a gf group, but note that an OVERLAY frame always has a spot in a gf
|
||||
// group,
|
||||
// even when show_existing_frame is used.
|
||||
if (!cpi->common.show_existing_frame || cpi->rc.is_src_frame_alt_ref) {
|
||||
av1_twopass_postencode_update(cpi);
|
||||
}
|
||||
av1_twopass_postencode_update(cpi);
|
||||
update_rc_counts(cpi);
|
||||
check_show_existing_frame(cpi);
|
||||
return AOM_CODEC_OK;
|
||||
}
|
||||
|
|
@ -5734,7 +5710,7 @@ static int is_integer_mv(AV1_COMP *cpi, const YV12_BUFFER_CONFIG *cur_picture,
|
|||
av1_get_block_hash_value(
|
||||
cur_picture->y_buffer + y_pos * stride_cur + x_pos, stride_cur,
|
||||
block_size, &hash_value_1, &hash_value_2,
|
||||
(cur_picture->flags & YV12_FLAG_HIGHBITDEPTH));
|
||||
(cur_picture->flags & YV12_FLAG_HIGHBITDEPTH), &cpi->td.mb);
|
||||
// Hashing does not work for highbitdepth currently.
|
||||
// TODO(Roger): Make it work for highbitdepth.
|
||||
if (av1_use_hash_me(&cpi->common)) {
|
||||
|
|
@ -5822,13 +5798,6 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
|
|||
|
||||
set_high_precision_mv(cpi, ALTREF_HIGH_PRECISION_MV, 0);
|
||||
|
||||
// Is multi-arf enabled.
|
||||
// Note that at the moment multi_arf is only configured for 2 pass VBR
|
||||
if ((oxcf->pass == 2) && (cpi->oxcf.enable_auto_arf > 1))
|
||||
cpi->multi_arf_allowed = 1;
|
||||
else
|
||||
cpi->multi_arf_allowed = 0;
|
||||
|
||||
// Normal defaults
|
||||
cm->refresh_frame_context = oxcf->frame_parallel_decoding_mode
|
||||
? REFRESH_FRAME_CONTEXT_DISABLED
|
||||
|
|
@ -5850,16 +5819,20 @@ int av1_get_compressed_data(AV1_COMP *cpi, unsigned int *frame_flags,
|
|||
struct lookahead_entry *lookahead_src = NULL;
|
||||
if (cm->current_video_frame > 0)
|
||||
lookahead_src = av1_lookahead_peek(cpi->lookahead, 0);
|
||||
if (lookahead_src != NULL &&
|
||||
((cpi->oxcf.error_resilient_mode |
|
||||
((lookahead_src->flags & AOM_EFLAG_ERROR_RESILIENT) != 0)) ||
|
||||
(cpi->oxcf.s_frame_mode |
|
||||
((lookahead_src->flags & AOM_EFLAG_SET_S_FRAME) != 0))) &&
|
||||
!(rc->frames_to_key == 0 || (cpi->frame_flags & FRAMEFLAGS_KEY))) {
|
||||
cm->show_existing_frame = 0;
|
||||
|
||||
int use_show_existing = 1;
|
||||
if (lookahead_src != NULL) {
|
||||
const int is_error_resilient =
|
||||
cpi->oxcf.error_resilient_mode ||
|
||||
(lookahead_src->flags & AOM_EFLAG_ERROR_RESILIENT);
|
||||
const int is_s_frame = cpi->oxcf.s_frame_mode ||
|
||||
(lookahead_src->flags & AOM_EFLAG_SET_S_FRAME);
|
||||
const int is_key_frame =
|
||||
(rc->frames_to_key == 0) || (cpi->frame_flags & FRAMEFLAGS_KEY);
|
||||
use_show_existing = !(is_error_resilient || is_s_frame) || is_key_frame;
|
||||
}
|
||||
|
||||
if (oxcf->pass == 2 && cm->show_existing_frame) {
|
||||
if (oxcf->pass == 2 && cm->show_existing_frame && use_show_existing) {
|
||||
// Manage the source buffer and flush out the source frame that has been
|
||||
// coded already; Also get prepared for PSNR calculation if needed.
|
||||
if ((source = av1_lookahead_pop(cpi->lookahead, flush)) == NULL) {
|
||||
|
|
@ -6415,3 +6388,50 @@ int64_t ticks_to_timebase_units(const aom_rational_t *timebase, int64_t n) {
|
|||
const int64_t round = TICKS_PER_SEC * timebase->num / 2 - 1;
|
||||
return (n * timebase->den + round) / timebase->num / TICKS_PER_SEC;
|
||||
}
|
||||
|
||||
aom_fixed_buf_t *av1_get_global_headers(AV1_COMP *cpi) {
|
||||
if (!cpi) return NULL;
|
||||
|
||||
uint8_t header_buf[512] = { 0 };
|
||||
const uint32_t sequence_header_size =
|
||||
write_sequence_header_obu(cpi, &header_buf[0]);
|
||||
assert(sequence_header_size <= sizeof(header_buf));
|
||||
if (sequence_header_size == 0) return NULL;
|
||||
|
||||
const size_t obu_header_size = 1;
|
||||
const size_t size_field_size = aom_uleb_size_in_bytes(sequence_header_size);
|
||||
const size_t payload_offset = obu_header_size + size_field_size;
|
||||
|
||||
if (payload_offset + sequence_header_size > sizeof(header_buf)) return NULL;
|
||||
memmove(&header_buf[payload_offset], &header_buf[0], sequence_header_size);
|
||||
|
||||
if (write_obu_header(OBU_SEQUENCE_HEADER, 0, &header_buf[0]) !=
|
||||
obu_header_size) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t coded_size_field_size = 0;
|
||||
if (aom_uleb_encode(sequence_header_size, size_field_size,
|
||||
&header_buf[obu_header_size],
|
||||
&coded_size_field_size) != 0) {
|
||||
return NULL;
|
||||
}
|
||||
assert(coded_size_field_size == size_field_size);
|
||||
|
||||
aom_fixed_buf_t *global_headers =
|
||||
(aom_fixed_buf_t *)malloc(sizeof(*global_headers));
|
||||
if (!global_headers) return NULL;
|
||||
|
||||
const size_t global_header_buf_size =
|
||||
obu_header_size + size_field_size + sequence_header_size;
|
||||
|
||||
global_headers->buf = malloc(global_header_buf_size);
|
||||
if (!global_headers->buf) {
|
||||
free(global_headers);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(global_headers->buf, &header_buf[0], global_header_buf_size);
|
||||
global_headers->sz = global_header_buf_size;
|
||||
return global_headers;
|
||||
}
|
||||
|
|
|
|||
105
third_party/aom/av1/encoder/encoder.h
vendored
105
third_party/aom/av1/encoder/encoder.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_ENCODER_H_
|
||||
#define AV1_ENCODER_ENCODER_H_
|
||||
#ifndef AOM_AV1_ENCODER_ENCODER_H_
|
||||
#define AOM_AV1_ENCODER_ENCODER_H_
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
|
@ -142,7 +142,6 @@ typedef struct AV1EncoderConfig {
|
|||
int noise_sensitivity; // pre processing blur: recommendation 0
|
||||
int sharpness; // sharpening output: recommendation 0:
|
||||
int speed;
|
||||
int dev_sf;
|
||||
// maximum allowed bitrate for any intra frame in % of bitrate target.
|
||||
unsigned int rc_max_intra_bitrate_pct;
|
||||
// maximum allowed bitrate for any inter frame in % of bitrate target.
|
||||
|
|
@ -249,6 +248,7 @@ typedef struct AV1EncoderConfig {
|
|||
int min_gf_interval;
|
||||
int max_gf_interval;
|
||||
|
||||
int row_mt;
|
||||
int tile_columns;
|
||||
int tile_rows;
|
||||
int tile_width_count;
|
||||
|
|
@ -309,6 +309,9 @@ typedef struct AV1EncoderConfig {
|
|||
float noise_level;
|
||||
int noise_block_size;
|
||||
#endif
|
||||
|
||||
unsigned int chroma_subsampling_x;
|
||||
unsigned int chroma_subsampling_y;
|
||||
} AV1EncoderConfig;
|
||||
|
||||
static INLINE int is_lossless_requested(const AV1EncoderConfig *cfg) {
|
||||
|
|
@ -401,6 +404,43 @@ typedef struct FRAME_COUNTS {
|
|||
[SWITCHABLE_FILTERS];
|
||||
} FRAME_COUNTS;
|
||||
|
||||
#if CONFIG_COLLECT_INTER_MODE_RD_STATS
|
||||
#define INTER_MODE_RD_DATA_OVERALL_SIZE 6400
|
||||
|
||||
typedef struct {
|
||||
int ready;
|
||||
double a;
|
||||
double b;
|
||||
double dist_mean;
|
||||
double ld_mean;
|
||||
double sse_mean;
|
||||
double sse_sse_mean;
|
||||
double sse_ld_mean;
|
||||
int num;
|
||||
double dist_sum;
|
||||
double ld_sum;
|
||||
double sse_sum;
|
||||
double sse_sse_sum;
|
||||
double sse_ld_sum;
|
||||
} InterModeRdModel;
|
||||
|
||||
typedef struct {
|
||||
int idx;
|
||||
int64_t rd;
|
||||
} RdIdxPair;
|
||||
// TODO(angiebird): This is an estimated size. We still need to figure what is
|
||||
// the maximum number of modes.
|
||||
#define MAX_INTER_MODES 1024
|
||||
typedef struct inter_modes_info {
|
||||
int num;
|
||||
MB_MODE_INFO mbmi_arr[MAX_INTER_MODES];
|
||||
int mode_rate_arr[MAX_INTER_MODES];
|
||||
int64_t sse_arr[MAX_INTER_MODES];
|
||||
int64_t est_rd_arr[MAX_INTER_MODES];
|
||||
RdIdxPair rd_idx_pair_arr[MAX_INTER_MODES];
|
||||
} InterModesInfo;
|
||||
#endif
|
||||
|
||||
// TODO(jingning) All spatially adaptive variables should go to TileDataEnc.
|
||||
typedef struct TileDataEnc {
|
||||
TileInfo tile_info;
|
||||
|
|
@ -411,8 +451,18 @@ typedef struct TileDataEnc {
|
|||
CFL_CTX cfl;
|
||||
DECLARE_ALIGNED(16, FRAME_CONTEXT, tctx);
|
||||
uint8_t allow_update_cdf;
|
||||
#if CONFIG_COLLECT_INTER_MODE_RD_STATS
|
||||
InterModeRdModel inter_mode_rd_models[BLOCK_SIZES_ALL];
|
||||
InterModesInfo inter_modes_info;
|
||||
#endif
|
||||
} TileDataEnc;
|
||||
|
||||
typedef struct {
|
||||
TOKENEXTRA *start;
|
||||
TOKENEXTRA *stop;
|
||||
unsigned int count;
|
||||
} TOKENLIST;
|
||||
|
||||
typedef struct RD_COUNTS {
|
||||
int64_t comp_pred_diff[REFERENCE_MODES];
|
||||
// Stores number of 4x4 blocks using global motion per reference frame.
|
||||
|
|
@ -427,11 +477,14 @@ typedef struct ThreadData {
|
|||
FRAME_COUNTS *counts;
|
||||
PC_TREE *pc_tree;
|
||||
PC_TREE *pc_root[MAX_MIB_SIZE_LOG2 - MIN_MIB_SIZE_LOG2 + 1];
|
||||
uint32_t *hash_value_buffer[2][2];
|
||||
int32_t *wsrc_buf;
|
||||
int32_t *mask_buf;
|
||||
uint8_t *above_pred_buf;
|
||||
uint8_t *left_pred_buf;
|
||||
PALETTE_BUFFER *palette_buffer;
|
||||
CONV_BUF_TYPE *tmp_conv_dst;
|
||||
uint8_t *tmp_obmc_bufs[2];
|
||||
int intrabc_used_this_tile;
|
||||
} ThreadData;
|
||||
|
||||
|
|
@ -502,6 +555,7 @@ typedef struct AV1_COMP {
|
|||
int previous_index;
|
||||
int cur_poc; // DebugInfo
|
||||
|
||||
unsigned int row_mt;
|
||||
int scaled_ref_idx[REF_FRAMES];
|
||||
int ref_fb_idx[REF_FRAMES];
|
||||
int refresh_fb_idx; // ref frame buffer index to refresh
|
||||
|
|
@ -647,13 +701,12 @@ typedef struct AV1_COMP {
|
|||
|
||||
search_site_config ss_cfg;
|
||||
|
||||
int multi_arf_allowed;
|
||||
|
||||
TileDataEnc *tile_data;
|
||||
int allocated_tiles; // Keep track of memory allocated for tiles.
|
||||
|
||||
TOKENEXTRA *tile_tok[MAX_TILE_ROWS][MAX_TILE_COLS];
|
||||
unsigned int tok_count[MAX_TILE_ROWS][MAX_TILE_COLS];
|
||||
TOKENLIST *tplist[MAX_TILE_ROWS][MAX_TILE_COLS];
|
||||
|
||||
TileBufferEnc tile_buffers[MAX_TILE_ROWS][MAX_TILE_COLS];
|
||||
|
||||
|
|
@ -703,8 +756,13 @@ typedef struct AV1_COMP {
|
|||
#if CONFIG_DENOISE
|
||||
struct aom_denoise_and_model_t *denoise_and_model;
|
||||
#endif
|
||||
// Stores the default value of skip flag depending on chroma format
|
||||
// Set as 1 for monochrome and 3 for other color formats
|
||||
int default_interp_skip_flags;
|
||||
int preserve_arf_as_gld;
|
||||
} AV1_COMP;
|
||||
|
||||
// Must not be called more than once.
|
||||
void av1_initialize_enc(void);
|
||||
|
||||
struct AV1_COMP *av1_create_compressor(AV1EncoderConfig *oxcf,
|
||||
|
|
@ -833,6 +891,22 @@ static INLINE unsigned int allocated_tokens(TileInfo tile, int sb_size_log2,
|
|||
return get_token_alloc(tile_mb_rows, tile_mb_cols, sb_size_log2, num_planes);
|
||||
}
|
||||
|
||||
static INLINE void get_start_tok(AV1_COMP *cpi, int tile_row, int tile_col,
|
||||
int mi_row, TOKENEXTRA **tok, int sb_size_log2,
|
||||
int num_planes) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
const int tile_cols = cm->tile_cols;
|
||||
TileDataEnc *this_tile = &cpi->tile_data[tile_row * tile_cols + tile_col];
|
||||
const TileInfo *const tile_info = &this_tile->tile_info;
|
||||
|
||||
const int tile_mb_cols =
|
||||
(tile_info->mi_col_end - tile_info->mi_col_start + 2) >> 2;
|
||||
const int tile_mb_row = (mi_row - tile_info->mi_row_start + 2) >> 2;
|
||||
|
||||
*tok = cpi->tile_tok[tile_row][tile_col] +
|
||||
get_token_alloc(tile_mb_row, tile_mb_cols, sb_size_log2, num_planes);
|
||||
}
|
||||
|
||||
void av1_apply_encoding_flags(AV1_COMP *cpi, aom_enc_frame_flags_t flags);
|
||||
|
||||
#define ALT_MIN_LAG 3
|
||||
|
|
@ -885,8 +959,27 @@ static INLINE int av1_frame_scaled(const AV1_COMMON *cm) {
|
|||
return !av1_superres_scaled(cm) && av1_resize_scaled(cm);
|
||||
}
|
||||
|
||||
// Don't allow a show_existing_frame to coincide with an error resilient
|
||||
// frame. An exception can be made for a forward keyframe since it has no
|
||||
// previous dependencies.
|
||||
static INLINE int encode_show_existing_frame(const AV1_COMMON *cm) {
|
||||
return cm->show_existing_frame &&
|
||||
(!cm->error_resilient_mode || cm->frame_type == KEY_FRAME);
|
||||
}
|
||||
|
||||
// Returns a Sequence Header OBU stored in an aom_fixed_buf_t, or NULL upon
|
||||
// failure. When a non-NULL aom_fixed_buf_t pointer is returned by this
|
||||
// function, the memory must be freed by the caller. Both the buf member of the
|
||||
// aom_fixed_buf_t, and the aom_fixed_buf_t pointer itself must be freed. Memory
|
||||
// returned must be freed via call to free().
|
||||
//
|
||||
// Note: The OBU returned is in Low Overhead Bitstream Format. Specifically,
|
||||
// the obu_has_size_field bit is set, and the buffer contains the obu_size
|
||||
// field.
|
||||
aom_fixed_buf_t *av1_get_global_headers(AV1_COMP *cpi);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_ENCODER_H_
|
||||
#endif // AOM_AV1_ENCODER_ENCODER_H_
|
||||
|
|
|
|||
48
third_party/aom/av1/encoder/encodetxb.c
vendored
48
third_party/aom/av1/encoder/encodetxb.c
vendored
|
|
@ -133,6 +133,38 @@ static INLINE int64_t get_coeff_dist(tran_low_t tcoeff, tran_low_t dqcoeff,
|
|||
return error;
|
||||
}
|
||||
|
||||
static const int8_t eob_to_pos_small[33] = {
|
||||
0, 1, 2, // 0-2
|
||||
3, 3, // 3-4
|
||||
4, 4, 4, 4, // 5-8
|
||||
5, 5, 5, 5, 5, 5, 5, 5, // 9-16
|
||||
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 // 17-32
|
||||
};
|
||||
|
||||
static const int8_t eob_to_pos_large[17] = {
|
||||
6, // place holder
|
||||
7, // 33-64
|
||||
8, 8, // 65-128
|
||||
9, 9, 9, 9, // 129-256
|
||||
10, 10, 10, 10, 10, 10, 10, 10, // 257-512
|
||||
11 // 513-
|
||||
};
|
||||
|
||||
static INLINE int get_eob_pos_token(const int eob, int *const extra) {
|
||||
int t;
|
||||
|
||||
if (eob < 33) {
|
||||
t = eob_to_pos_small[eob];
|
||||
} else {
|
||||
const int e = AOMMIN((eob - 1) >> 5, 16);
|
||||
t = eob_to_pos_large[e];
|
||||
}
|
||||
|
||||
*extra = eob - k_eob_group_start[t];
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
#if CONFIG_ENTROPY_STATS
|
||||
void av1_update_eob_context(int cdf_idx, int eob, TX_SIZE tx_size,
|
||||
TX_CLASS tx_class, PLANE_TYPE plane,
|
||||
|
|
@ -464,8 +496,12 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
|
|||
aom_writer *w, int blk_row, int blk_col, int plane,
|
||||
TX_SIZE tx_size, const tran_low_t *tcoeff,
|
||||
uint16_t eob, TXB_CTX *txb_ctx) {
|
||||
const PLANE_TYPE plane_type = get_plane_type(plane);
|
||||
const TX_SIZE txs_ctx = get_txsize_entropy_ctx(tx_size);
|
||||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
aom_write_symbol(w, eob == 0,
|
||||
ec_ctx->txb_skip_cdf[txs_ctx][txb_ctx->txb_skip_ctx], 2);
|
||||
if (eob == 0) return;
|
||||
const PLANE_TYPE plane_type = get_plane_type(plane);
|
||||
const TX_TYPE tx_type = av1_get_tx_type(plane_type, xd, blk_row, blk_col,
|
||||
tx_size, cm->reduced_tx_set_used);
|
||||
const TX_CLASS tx_class = tx_type_to_class[tx_type];
|
||||
|
|
@ -475,18 +511,10 @@ void av1_write_coeffs_txb(const AV1_COMMON *const cm, MACROBLOCKD *xd,
|
|||
const int bwl = get_txb_bwl(tx_size);
|
||||
const int width = get_txb_wide(tx_size);
|
||||
const int height = get_txb_high(tx_size);
|
||||
FRAME_CONTEXT *ec_ctx = xd->tile_ctx;
|
||||
|
||||
uint8_t levels_buf[TX_PAD_2D];
|
||||
uint8_t *const levels = set_levels(levels_buf, width);
|
||||
DECLARE_ALIGNED(16, int8_t, coeff_contexts[MAX_TX_SQUARE]);
|
||||
|
||||
aom_write_symbol(w, eob == 0,
|
||||
ec_ctx->txb_skip_cdf[txs_ctx][txb_ctx->txb_skip_ctx], 2);
|
||||
if (plane == 0 && eob == 0) {
|
||||
assert(tx_type == DCT_DCT);
|
||||
}
|
||||
if (eob == 0) return;
|
||||
|
||||
av1_txb_init_levels(tcoeff, width, height, levels);
|
||||
|
||||
av1_write_tx_type(cm, xd, blk_row, blk_col, plane, tx_size, w);
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/encodetxb.h
vendored
6
third_party/aom/av1/encoder/encodetxb.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef ENCODETXB_H_
|
||||
#define ENCODETXB_H_
|
||||
#ifndef AOM_AV1_ENCODER_ENCODETXB_H_
|
||||
#define AOM_AV1_ENCODER_ENCODETXB_H_
|
||||
|
||||
#include "config/aom_config.h"
|
||||
|
||||
|
|
@ -84,4 +84,4 @@ int av1_optimize_txb_new(const struct AV1_COMP *cpi, MACROBLOCK *x, int plane,
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif // COEFFS_CODING_H_
|
||||
#endif // AOM_AV1_ENCODER_ENCODETXB_H_
|
||||
|
|
|
|||
254
third_party/aom/av1/encoder/ethread.c
vendored
254
third_party/aom/av1/encoder/ethread.c
vendored
|
|
@ -27,7 +27,8 @@ static void accumulate_rd_opt(ThreadData *td, ThreadData *td_t) {
|
|||
td->rd_counts.skip_mode_used_flag |= td_t->rd_counts.skip_mode_used_flag;
|
||||
}
|
||||
|
||||
static int enc_worker_hook(EncWorkerData *const thread_data, void *unused) {
|
||||
static int enc_worker_hook(void *arg1, void *unused) {
|
||||
EncWorkerData *const thread_data = (EncWorkerData *)arg1;
|
||||
AV1_COMP *const cpi = thread_data->cpi;
|
||||
const AV1_COMMON *const cm = &cpi->common;
|
||||
const int tile_cols = cm->tile_cols;
|
||||
|
|
@ -47,110 +48,97 @@ static int enc_worker_hook(EncWorkerData *const thread_data, void *unused) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
void av1_encode_tiles_mt(AV1_COMP *cpi) {
|
||||
static void create_enc_workers(AV1_COMP *cpi, int num_workers) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
const int tile_cols = cm->tile_cols;
|
||||
const AVxWorkerInterface *const winterface = aom_get_worker_interface();
|
||||
int num_workers = AOMMIN(cpi->oxcf.max_threads, tile_cols);
|
||||
int i;
|
||||
|
||||
av1_init_tile_data(cpi);
|
||||
CHECK_MEM_ERROR(cm, cpi->workers,
|
||||
aom_malloc(num_workers * sizeof(*cpi->workers)));
|
||||
|
||||
// Only run once to create threads and allocate thread data.
|
||||
if (cpi->num_workers == 0) {
|
||||
CHECK_MEM_ERROR(cm, cpi->workers,
|
||||
aom_malloc(num_workers * sizeof(*cpi->workers)));
|
||||
CHECK_MEM_ERROR(cm, cpi->tile_thr_data,
|
||||
aom_calloc(num_workers, sizeof(*cpi->tile_thr_data)));
|
||||
|
||||
CHECK_MEM_ERROR(cm, cpi->tile_thr_data,
|
||||
aom_calloc(num_workers, sizeof(*cpi->tile_thr_data)));
|
||||
|
||||
for (i = 0; i < num_workers; i++) {
|
||||
AVxWorker *const worker = &cpi->workers[i];
|
||||
EncWorkerData *const thread_data = &cpi->tile_thr_data[i];
|
||||
|
||||
++cpi->num_workers;
|
||||
winterface->init(worker);
|
||||
|
||||
thread_data->cpi = cpi;
|
||||
|
||||
if (i < num_workers - 1) {
|
||||
// Allocate thread data.
|
||||
CHECK_MEM_ERROR(cm, thread_data->td,
|
||||
aom_memalign(32, sizeof(*thread_data->td)));
|
||||
av1_zero(*thread_data->td);
|
||||
|
||||
// Set up pc_tree.
|
||||
thread_data->td->pc_tree = NULL;
|
||||
av1_setup_pc_tree(cm, thread_data->td);
|
||||
|
||||
CHECK_MEM_ERROR(cm, thread_data->td->above_pred_buf,
|
||||
(uint8_t *)aom_memalign(
|
||||
16, MAX_MB_PLANE * MAX_SB_SQUARE *
|
||||
sizeof(*thread_data->td->above_pred_buf)));
|
||||
CHECK_MEM_ERROR(cm, thread_data->td->left_pred_buf,
|
||||
(uint8_t *)aom_memalign(
|
||||
16, MAX_MB_PLANE * MAX_SB_SQUARE *
|
||||
sizeof(*thread_data->td->left_pred_buf)));
|
||||
|
||||
CHECK_MEM_ERROR(
|
||||
cm, thread_data->td->wsrc_buf,
|
||||
(int32_t *)aom_memalign(
|
||||
16, MAX_SB_SQUARE * sizeof(*thread_data->td->wsrc_buf)));
|
||||
CHECK_MEM_ERROR(
|
||||
cm, thread_data->td->mask_buf,
|
||||
(int32_t *)aom_memalign(
|
||||
16, MAX_SB_SQUARE * sizeof(*thread_data->td->mask_buf)));
|
||||
// Allocate frame counters in thread data.
|
||||
CHECK_MEM_ERROR(cm, thread_data->td->counts,
|
||||
aom_calloc(1, sizeof(*thread_data->td->counts)));
|
||||
|
||||
// Allocate buffers used by palette coding mode.
|
||||
CHECK_MEM_ERROR(
|
||||
cm, thread_data->td->palette_buffer,
|
||||
aom_memalign(16, sizeof(*thread_data->td->palette_buffer)));
|
||||
|
||||
// Create threads
|
||||
if (!winterface->reset(worker))
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR,
|
||||
"Tile encoder thread creation failed");
|
||||
} else {
|
||||
// Main thread acts as a worker and uses the thread data in cpi.
|
||||
thread_data->td = &cpi->td;
|
||||
}
|
||||
|
||||
winterface->sync(worker);
|
||||
}
|
||||
} else {
|
||||
num_workers = AOMMIN(num_workers, cpi->num_workers);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_workers; i++) {
|
||||
for (int i = 0; i < num_workers; i++) {
|
||||
AVxWorker *const worker = &cpi->workers[i];
|
||||
EncWorkerData *const thread_data = &cpi->tile_thr_data[i];
|
||||
|
||||
worker->hook = (AVxWorkerHook)enc_worker_hook;
|
||||
worker->data1 = thread_data;
|
||||
worker->data2 = NULL;
|
||||
++cpi->num_workers;
|
||||
winterface->init(worker);
|
||||
|
||||
// Before encoding a frame, copy the thread data from cpi.
|
||||
if (thread_data->td != &cpi->td) {
|
||||
thread_data->td->mb = cpi->td.mb;
|
||||
thread_data->td->rd_counts = cpi->td.rd_counts;
|
||||
thread_data->td->mb.above_pred_buf = thread_data->td->above_pred_buf;
|
||||
thread_data->td->mb.left_pred_buf = thread_data->td->left_pred_buf;
|
||||
thread_data->td->mb.wsrc_buf = thread_data->td->wsrc_buf;
|
||||
thread_data->td->mb.mask_buf = thread_data->td->mask_buf;
|
||||
}
|
||||
if (thread_data->td->counts != &cpi->counts) {
|
||||
memcpy(thread_data->td->counts, &cpi->counts, sizeof(cpi->counts));
|
||||
}
|
||||
thread_data->cpi = cpi;
|
||||
|
||||
if (i < num_workers - 1)
|
||||
thread_data->td->mb.palette_buffer = thread_data->td->palette_buffer;
|
||||
if (i < num_workers - 1) {
|
||||
// Allocate thread data.
|
||||
CHECK_MEM_ERROR(cm, thread_data->td,
|
||||
aom_memalign(32, sizeof(*thread_data->td)));
|
||||
av1_zero(*thread_data->td);
|
||||
|
||||
// Set up pc_tree.
|
||||
thread_data->td->pc_tree = NULL;
|
||||
av1_setup_pc_tree(cm, thread_data->td);
|
||||
|
||||
CHECK_MEM_ERROR(cm, thread_data->td->above_pred_buf,
|
||||
(uint8_t *)aom_memalign(
|
||||
16, MAX_MB_PLANE * MAX_SB_SQUARE *
|
||||
sizeof(*thread_data->td->above_pred_buf)));
|
||||
CHECK_MEM_ERROR(cm, thread_data->td->left_pred_buf,
|
||||
(uint8_t *)aom_memalign(
|
||||
16, MAX_MB_PLANE * MAX_SB_SQUARE *
|
||||
sizeof(*thread_data->td->left_pred_buf)));
|
||||
|
||||
CHECK_MEM_ERROR(
|
||||
cm, thread_data->td->wsrc_buf,
|
||||
(int32_t *)aom_memalign(
|
||||
16, MAX_SB_SQUARE * sizeof(*thread_data->td->wsrc_buf)));
|
||||
|
||||
for (int x = 0; x < 2; x++)
|
||||
for (int y = 0; y < 2; y++)
|
||||
CHECK_MEM_ERROR(
|
||||
cm, thread_data->td->hash_value_buffer[x][y],
|
||||
(uint32_t *)aom_malloc(
|
||||
AOM_BUFFER_SIZE_FOR_BLOCK_HASH *
|
||||
sizeof(*thread_data->td->hash_value_buffer[0][0])));
|
||||
|
||||
CHECK_MEM_ERROR(
|
||||
cm, thread_data->td->mask_buf,
|
||||
(int32_t *)aom_memalign(
|
||||
16, MAX_SB_SQUARE * sizeof(*thread_data->td->mask_buf)));
|
||||
// Allocate frame counters in thread data.
|
||||
CHECK_MEM_ERROR(cm, thread_data->td->counts,
|
||||
aom_calloc(1, sizeof(*thread_data->td->counts)));
|
||||
|
||||
// Allocate buffers used by palette coding mode.
|
||||
CHECK_MEM_ERROR(
|
||||
cm, thread_data->td->palette_buffer,
|
||||
aom_memalign(16, sizeof(*thread_data->td->palette_buffer)));
|
||||
|
||||
CHECK_MEM_ERROR(
|
||||
cm, thread_data->td->tmp_conv_dst,
|
||||
aom_memalign(32, MAX_SB_SIZE * MAX_SB_SIZE *
|
||||
sizeof(*thread_data->td->tmp_conv_dst)));
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
CHECK_MEM_ERROR(
|
||||
cm, thread_data->td->tmp_obmc_bufs[j],
|
||||
aom_memalign(16, 2 * MAX_MB_PLANE * MAX_SB_SQUARE *
|
||||
sizeof(*thread_data->td->tmp_obmc_bufs[j])));
|
||||
}
|
||||
|
||||
// Create threads
|
||||
if (!winterface->reset(worker))
|
||||
aom_internal_error(&cm->error, AOM_CODEC_ERROR,
|
||||
"Tile encoder thread creation failed");
|
||||
} else {
|
||||
// Main thread acts as a worker and uses the thread data in cpi.
|
||||
thread_data->td = &cpi->td;
|
||||
}
|
||||
winterface->sync(worker);
|
||||
}
|
||||
}
|
||||
|
||||
static void launch_enc_workers(AV1_COMP *cpi, int num_workers) {
|
||||
const AVxWorkerInterface *const winterface = aom_get_worker_interface();
|
||||
// Encode a frame
|
||||
for (i = 0; i < num_workers; i++) {
|
||||
for (int i = 0; i < num_workers; i++) {
|
||||
AVxWorker *const worker = &cpi->workers[i];
|
||||
EncWorkerData *const thread_data = (EncWorkerData *)worker->data1;
|
||||
|
||||
|
|
@ -162,14 +150,20 @@ void av1_encode_tiles_mt(AV1_COMP *cpi) {
|
|||
else
|
||||
winterface->launch(worker);
|
||||
}
|
||||
}
|
||||
|
||||
static void sync_enc_workers(AV1_COMP *cpi, int num_workers) {
|
||||
const AVxWorkerInterface *const winterface = aom_get_worker_interface();
|
||||
|
||||
// Encoding ends.
|
||||
for (i = 0; i < num_workers; i++) {
|
||||
for (int i = 0; i < num_workers; i++) {
|
||||
AVxWorker *const worker = &cpi->workers[i];
|
||||
winterface->sync(worker);
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < num_workers; i++) {
|
||||
static void accumulate_counters_enc_workers(AV1_COMP *cpi, int num_workers) {
|
||||
for (int i = 0; i < num_workers; i++) {
|
||||
AVxWorker *const worker = &cpi->workers[i];
|
||||
EncWorkerData *const thread_data = (EncWorkerData *)worker->data1;
|
||||
cpi->intrabc_used |= thread_data->td->intrabc_used_this_tile;
|
||||
|
|
@ -182,6 +176,78 @@ void av1_encode_tiles_mt(AV1_COMP *cpi) {
|
|||
}
|
||||
}
|
||||
|
||||
static void prepare_enc_workers(AV1_COMP *cpi, AVxWorkerHook hook,
|
||||
int num_workers) {
|
||||
for (int i = 0; i < num_workers; i++) {
|
||||
AVxWorker *const worker = &cpi->workers[i];
|
||||
EncWorkerData *const thread_data = &cpi->tile_thr_data[i];
|
||||
|
||||
worker->hook = hook;
|
||||
worker->data1 = thread_data;
|
||||
worker->data2 = NULL;
|
||||
|
||||
// Before encoding a frame, copy the thread data from cpi.
|
||||
if (thread_data->td != &cpi->td) {
|
||||
thread_data->td->mb = cpi->td.mb;
|
||||
thread_data->td->rd_counts = cpi->td.rd_counts;
|
||||
thread_data->td->mb.above_pred_buf = thread_data->td->above_pred_buf;
|
||||
thread_data->td->mb.left_pred_buf = thread_data->td->left_pred_buf;
|
||||
thread_data->td->mb.wsrc_buf = thread_data->td->wsrc_buf;
|
||||
for (int x = 0; x < 2; x++) {
|
||||
for (int y = 0; y < 2; y++) {
|
||||
memcpy(thread_data->td->hash_value_buffer[x][y],
|
||||
cpi->td.mb.hash_value_buffer[x][y],
|
||||
AOM_BUFFER_SIZE_FOR_BLOCK_HASH *
|
||||
sizeof(*thread_data->td->hash_value_buffer[0][0]));
|
||||
thread_data->td->mb.hash_value_buffer[x][y] =
|
||||
thread_data->td->hash_value_buffer[x][y];
|
||||
}
|
||||
}
|
||||
thread_data->td->mb.mask_buf = thread_data->td->mask_buf;
|
||||
}
|
||||
if (thread_data->td->counts != &cpi->counts) {
|
||||
memcpy(thread_data->td->counts, &cpi->counts, sizeof(cpi->counts));
|
||||
}
|
||||
|
||||
if (i < num_workers - 1) {
|
||||
thread_data->td->mb.palette_buffer = thread_data->td->palette_buffer;
|
||||
thread_data->td->mb.tmp_conv_dst = thread_data->td->tmp_conv_dst;
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
thread_data->td->mb.tmp_obmc_bufs[j] =
|
||||
thread_data->td->tmp_obmc_bufs[j];
|
||||
}
|
||||
|
||||
thread_data->td->mb.e_mbd.tmp_conv_dst = thread_data->td->mb.tmp_conv_dst;
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
thread_data->td->mb.e_mbd.tmp_obmc_bufs[j] =
|
||||
thread_data->td->mb.tmp_obmc_bufs[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void av1_encode_tiles_mt(AV1_COMP *cpi) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
const int tile_cols = cm->tile_cols;
|
||||
const int tile_rows = cm->tile_rows;
|
||||
int num_workers = AOMMIN(cpi->oxcf.max_threads, tile_cols * tile_rows);
|
||||
|
||||
if (cpi->tile_data == NULL || cpi->allocated_tiles < tile_cols * tile_rows)
|
||||
av1_alloc_tile_data(cpi);
|
||||
|
||||
av1_init_tile_data(cpi);
|
||||
// Only run once to create threads and allocate thread data.
|
||||
if (cpi->num_workers == 0) {
|
||||
create_enc_workers(cpi, num_workers);
|
||||
} else {
|
||||
num_workers = AOMMIN(num_workers, cpi->num_workers);
|
||||
}
|
||||
prepare_enc_workers(cpi, enc_worker_hook, num_workers);
|
||||
launch_enc_workers(cpi, num_workers);
|
||||
sync_enc_workers(cpi, num_workers);
|
||||
accumulate_counters_enc_workers(cpi, num_workers);
|
||||
}
|
||||
|
||||
// Accumulate frame counts. FRAME_COUNTS consist solely of 'unsigned int'
|
||||
// members, so we treat it as an array, and sum over the whole length.
|
||||
void av1_accumulate_frame_counts(FRAME_COUNTS *acc_counts,
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/ethread.h
vendored
6
third_party/aom/av1/encoder/ethread.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_ETHREAD_H_
|
||||
#define AV1_ENCODER_ETHREAD_H_
|
||||
#ifndef AOM_AV1_ENCODER_ETHREAD_H_
|
||||
#define AOM_AV1_ENCODER_ETHREAD_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -34,4 +34,4 @@ void av1_accumulate_frame_counts(struct FRAME_COUNTS *acc_counts,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_ETHREAD_H_
|
||||
#endif // AOM_AV1_ENCODER_ETHREAD_H_
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/extend.h
vendored
6
third_party/aom/av1/encoder/extend.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_EXTEND_H_
|
||||
#define AV1_ENCODER_EXTEND_H_
|
||||
#ifndef AOM_AV1_ENCODER_EXTEND_H_
|
||||
#define AOM_AV1_ENCODER_EXTEND_H_
|
||||
|
||||
#include "aom_scale/yv12config.h"
|
||||
#include "aom/aom_integer.h"
|
||||
|
|
@ -29,4 +29,4 @@ void av1_copy_and_extend_frame_with_rect(const YV12_BUFFER_CONFIG *src,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_EXTEND_H_
|
||||
#endif // AOM_AV1_ENCODER_EXTEND_H_
|
||||
|
|
|
|||
1002
third_party/aom/av1/encoder/firstpass.c
vendored
1002
third_party/aom/av1/encoder/firstpass.c
vendored
File diff suppressed because it is too large
Load diff
19
third_party/aom/av1/encoder/firstpass.h
vendored
19
third_party/aom/av1/encoder/firstpass.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_FIRSTPASS_H_
|
||||
#define AV1_ENCODER_FIRSTPASS_H_
|
||||
#ifndef AOM_AV1_ENCODER_FIRSTPASS_H_
|
||||
#define AOM_AV1_ENCODER_FIRSTPASS_H_
|
||||
|
||||
#include "av1/common/enums.h"
|
||||
#include "av1/common/onyxc_int.h"
|
||||
|
|
@ -47,15 +47,7 @@ typedef struct {
|
|||
// number of bi-predictive frames.
|
||||
#define BFG_INTERVAL 2
|
||||
// The maximum number of extra ALTREF's except ALTREF_FRAME
|
||||
// NOTE: REF_FRAMES indicates the maximum number of frames that may be buffered
|
||||
// to serve as references. Currently REF_FRAMES == 8.
|
||||
#define USE_GF16_MULTI_LAYER 0
|
||||
|
||||
#if USE_GF16_MULTI_LAYER
|
||||
#define MAX_EXT_ARFS (REF_FRAMES - BWDREF_FRAME)
|
||||
#else // !USE_GF16_MULTI_LAYER
|
||||
#define MAX_EXT_ARFS (REF_FRAMES - BWDREF_FRAME - 1)
|
||||
#endif // USE_GF16_MULTI_LAYER
|
||||
|
||||
#define MIN_EXT_ARF_INTERVAL 4
|
||||
|
||||
|
|
@ -126,6 +118,7 @@ typedef struct {
|
|||
unsigned char arf_pos_in_gf[(MAX_LAG_BUFFERS * 2) + 1];
|
||||
unsigned char pyramid_level[(MAX_LAG_BUFFERS * 2) + 1];
|
||||
unsigned char pyramid_height;
|
||||
unsigned char pyramid_lvl_nodes[MAX_PYRAMID_LVL];
|
||||
#endif
|
||||
unsigned char brf_src_offset[(MAX_LAG_BUFFERS * 2) + 1];
|
||||
unsigned char bidir_pred_enabled[(MAX_LAG_BUFFERS * 2) + 1];
|
||||
|
|
@ -197,10 +190,6 @@ void av1_configure_buffer_updates_firstpass(struct AV1_COMP *cpi,
|
|||
// Post encode update of the rate control parameters for 2-pass
|
||||
void av1_twopass_postencode_update(struct AV1_COMP *cpi);
|
||||
|
||||
#if USE_GF16_MULTI_LAYER
|
||||
void av1_ref_frame_map_idx_updates(struct AV1_COMP *cpi, int gf_frame_index);
|
||||
#endif // USE_GF16_MULTI_LAYER
|
||||
|
||||
static INLINE int get_number_of_extra_arfs(int interval, int arf_pending) {
|
||||
if (arf_pending && MAX_EXT_ARFS > 0)
|
||||
return interval >= MIN_EXT_ARF_INTERVAL * (MAX_EXT_ARFS + 1)
|
||||
|
|
@ -216,4 +205,4 @@ static INLINE int get_number_of_extra_arfs(int interval, int arf_pending) {
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_FIRSTPASS_H_
|
||||
#endif // AOM_AV1_ENCODER_FIRSTPASS_H_
|
||||
|
|
|
|||
4
third_party/aom/av1/encoder/global_motion.c
vendored
4
third_party/aom/av1/encoder/global_motion.c
vendored
|
|
@ -32,8 +32,8 @@
|
|||
// Border over which to compute the global motion
|
||||
#define ERRORADV_BORDER 0
|
||||
|
||||
static const double erroradv_tr[] = { 0.75, 0.70, 0.65 };
|
||||
static const double erroradv_prod_tr[] = { 22000, 20000, 18000 };
|
||||
static const double erroradv_tr[] = { 0.65, 0.60, 0.55 };
|
||||
static const double erroradv_prod_tr[] = { 20000, 18000, 16000 };
|
||||
|
||||
int is_enough_erroradvantage(double best_erroradvantage, int params_cost,
|
||||
int erroradv_type) {
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/global_motion.h
vendored
6
third_party/aom/av1/encoder/global_motion.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_GLOBAL_MOTION_H_
|
||||
#define AV1_ENCODER_GLOBAL_MOTION_H_
|
||||
#ifndef AOM_AV1_ENCODER_GLOBAL_MOTION_H_
|
||||
#define AOM_AV1_ENCODER_GLOBAL_MOTION_H_
|
||||
|
||||
#include "aom/aom_integer.h"
|
||||
#include "aom_scale/yv12config.h"
|
||||
|
|
@ -61,4 +61,4 @@ int compute_global_motion_feature_based(TransformationType type,
|
|||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
#endif // AV1_ENCODER_GLOBAL_MOTION_H_
|
||||
#endif // AOM_AV1_ENCODER_GLOBAL_MOTION_H_
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
#ifndef AV1_GRAIN_TEST_VECTORS_H_
|
||||
#define AV1_GRAIN_TEST_VECTORS_H_
|
||||
#ifndef AOM_AV1_ENCODER_GRAIN_TEST_VECTORS_H_
|
||||
#define AOM_AV1_ENCODER_GRAIN_TEST_VECTORS_H_
|
||||
|
||||
/* Test vectors for emulation of different film grain types.
|
||||
* Note that bit depth would be derived from the bitstream and
|
||||
|
|
@ -778,4 +778,4 @@ static aom_film_grain_t film_grain_test_vectors[16] = {
|
|||
45231 /* random_seed */
|
||||
},
|
||||
};
|
||||
#endif // AV1_GRAIN_TEST_VECTORS_H_
|
||||
#endif // AOM_AV1_ENCODER_GRAIN_TEST_VECTORS_H_
|
||||
|
|
|
|||
8
third_party/aom/av1/encoder/hash.h
vendored
8
third_party/aom/av1/encoder/hash.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_HASH_H_
|
||||
#define AV1_ENCODER_HASH_H_
|
||||
#ifndef AOM_AV1_ENCODER_HASH_H_
|
||||
#define AOM_AV1_ENCODER_HASH_H_
|
||||
|
||||
#include "config/aom_config.h"
|
||||
|
||||
|
|
@ -43,8 +43,10 @@ typedef struct _CRC32C {
|
|||
// init table for software version crc32c
|
||||
void av1_crc32c_calculator_init(CRC32C *p_crc32c);
|
||||
|
||||
#define AOM_BUFFER_SIZE_FOR_BLOCK_HASH (4096)
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_HASH_H_
|
||||
#endif // AOM_AV1_ENCODER_HASH_H_
|
||||
|
|
|
|||
94
third_party/aom/av1/encoder/hash_motion.c
vendored
94
third_party/aom/av1/encoder/hash_motion.c
vendored
|
|
@ -13,14 +13,12 @@
|
|||
|
||||
#include "config/av1_rtcd.h"
|
||||
|
||||
#include "av1/encoder/block.h"
|
||||
#include "av1/encoder/hash.h"
|
||||
#include "av1/encoder/hash_motion.h"
|
||||
|
||||
static const int crc_bits = 16;
|
||||
static const int block_size_bits = 3;
|
||||
static CRC_CALCULATOR crc_calculator1;
|
||||
static CRC_CALCULATOR crc_calculator2;
|
||||
static int g_crc_initialized = 0;
|
||||
|
||||
static void hash_table_clear_all(hash_table *p_hash_table) {
|
||||
if (p_hash_table->p_lookup_table == NULL) {
|
||||
|
|
@ -106,11 +104,11 @@ static int hash_block_size_to_index(int block_size) {
|
|||
}
|
||||
}
|
||||
|
||||
void av1_hash_table_init(hash_table *p_hash_table) {
|
||||
if (g_crc_initialized == 0) {
|
||||
av1_crc_calculator_init(&crc_calculator1, 24, 0x5D6DCB);
|
||||
av1_crc_calculator_init(&crc_calculator2, 24, 0x864CFB);
|
||||
g_crc_initialized = 1;
|
||||
void av1_hash_table_init(hash_table *p_hash_table, MACROBLOCK *x) {
|
||||
if (x->g_crc_initialized == 0) {
|
||||
av1_crc_calculator_init(&x->crc_calculator1, 24, 0x5D6DCB);
|
||||
av1_crc_calculator_init(&x->crc_calculator2, 24, 0x864CFB);
|
||||
x->g_crc_initialized = 1;
|
||||
}
|
||||
p_hash_table->p_lookup_table = NULL;
|
||||
}
|
||||
|
|
@ -181,7 +179,8 @@ int32_t av1_has_exact_match(hash_table *p_hash_table, uint32_t hash_value1,
|
|||
|
||||
void av1_generate_block_2x2_hash_value(const YV12_BUFFER_CONFIG *picture,
|
||||
uint32_t *pic_block_hash[2],
|
||||
int8_t *pic_block_same_info[3]) {
|
||||
int8_t *pic_block_same_info[3],
|
||||
MACROBLOCK *x) {
|
||||
const int width = 2;
|
||||
const int height = 2;
|
||||
const int x_end = picture->y_crop_width - width + 1;
|
||||
|
|
@ -201,9 +200,9 @@ void av1_generate_block_2x2_hash_value(const YV12_BUFFER_CONFIG *picture,
|
|||
pic_block_same_info[1][pos] = is_block16_2x2_col_same_value(p);
|
||||
|
||||
pic_block_hash[0][pos] = av1_get_crc_value(
|
||||
&crc_calculator1, (uint8_t *)p, length * sizeof(p[0]));
|
||||
&x->crc_calculator1, (uint8_t *)p, length * sizeof(p[0]));
|
||||
pic_block_hash[1][pos] = av1_get_crc_value(
|
||||
&crc_calculator2, (uint8_t *)p, length * sizeof(p[0]));
|
||||
&x->crc_calculator2, (uint8_t *)p, length * sizeof(p[0]));
|
||||
pos++;
|
||||
}
|
||||
pos += width - 1;
|
||||
|
|
@ -220,9 +219,9 @@ void av1_generate_block_2x2_hash_value(const YV12_BUFFER_CONFIG *picture,
|
|||
pic_block_same_info[1][pos] = is_block_2x2_col_same_value(p);
|
||||
|
||||
pic_block_hash[0][pos] =
|
||||
av1_get_crc_value(&crc_calculator1, p, length * sizeof(p[0]));
|
||||
av1_get_crc_value(&x->crc_calculator1, p, length * sizeof(p[0]));
|
||||
pic_block_hash[1][pos] =
|
||||
av1_get_crc_value(&crc_calculator2, p, length * sizeof(p[0]));
|
||||
av1_get_crc_value(&x->crc_calculator2, p, length * sizeof(p[0]));
|
||||
pos++;
|
||||
}
|
||||
pos += width - 1;
|
||||
|
|
@ -235,7 +234,8 @@ void av1_generate_block_hash_value(const YV12_BUFFER_CONFIG *picture,
|
|||
uint32_t *src_pic_block_hash[2],
|
||||
uint32_t *dst_pic_block_hash[2],
|
||||
int8_t *src_pic_block_same_info[3],
|
||||
int8_t *dst_pic_block_same_info[3]) {
|
||||
int8_t *dst_pic_block_same_info[3],
|
||||
MACROBLOCK *x) {
|
||||
const int pic_width = picture->y_crop_width;
|
||||
const int x_end = picture->y_crop_width - block_size + 1;
|
||||
const int y_end = picture->y_crop_height - block_size + 1;
|
||||
|
|
@ -254,14 +254,14 @@ void av1_generate_block_hash_value(const YV12_BUFFER_CONFIG *picture,
|
|||
p[2] = src_pic_block_hash[0][pos + src_size * pic_width];
|
||||
p[3] = src_pic_block_hash[0][pos + src_size * pic_width + src_size];
|
||||
dst_pic_block_hash[0][pos] =
|
||||
av1_get_crc_value(&crc_calculator1, (uint8_t *)p, length);
|
||||
av1_get_crc_value(&x->crc_calculator1, (uint8_t *)p, length);
|
||||
|
||||
p[0] = src_pic_block_hash[1][pos];
|
||||
p[1] = src_pic_block_hash[1][pos + src_size];
|
||||
p[2] = src_pic_block_hash[1][pos + src_size * pic_width];
|
||||
p[3] = src_pic_block_hash[1][pos + src_size * pic_width + src_size];
|
||||
dst_pic_block_hash[1][pos] =
|
||||
av1_get_crc_value(&crc_calculator2, (uint8_t *)p, length);
|
||||
av1_get_crc_value(&x->crc_calculator2, (uint8_t *)p, length);
|
||||
|
||||
dst_pic_block_same_info[0][pos] =
|
||||
src_pic_block_same_info[0][pos] &&
|
||||
|
|
@ -388,17 +388,9 @@ int av1_hash_is_vertical_perfect(const YV12_BUFFER_CONFIG *picture,
|
|||
return 1;
|
||||
}
|
||||
|
||||
// global buffer for hash value calculation of a block
|
||||
// used only in av1_get_block_hash_value()
|
||||
#define AOM_BUFFER_SIZE_FOR_BLOCK_HASH (4096)
|
||||
// [first hash/second hash]
|
||||
// [two buffers used ping-pong]
|
||||
// [num of 2x2 blocks in 128x128]
|
||||
static uint32_t hash_value_buffer[2][2][AOM_BUFFER_SIZE_FOR_BLOCK_HASH];
|
||||
|
||||
void av1_get_block_hash_value(uint8_t *y_src, int stride, int block_size,
|
||||
uint32_t *hash_value1, uint32_t *hash_value2,
|
||||
int use_highbitdepth) {
|
||||
int use_highbitdepth, MACROBLOCK *x) {
|
||||
uint32_t to_hash[4];
|
||||
const int add_value = hash_block_size_to_index(block_size) << crc_bits;
|
||||
assert(add_value >= 0);
|
||||
|
|
@ -415,10 +407,12 @@ void av1_get_block_hash_value(uint8_t *y_src, int stride, int block_size,
|
|||
get_pixels_in_1D_short_array_by_block_2x2(
|
||||
y16_src + y_pos * stride + x_pos, stride, pixel_to_hash);
|
||||
assert(pos < AOM_BUFFER_SIZE_FOR_BLOCK_HASH);
|
||||
hash_value_buffer[0][0][pos] = av1_get_crc_value(
|
||||
&crc_calculator1, (uint8_t *)pixel_to_hash, sizeof(pixel_to_hash));
|
||||
hash_value_buffer[1][0][pos] = av1_get_crc_value(
|
||||
&crc_calculator2, (uint8_t *)pixel_to_hash, sizeof(pixel_to_hash));
|
||||
x->hash_value_buffer[0][0][pos] =
|
||||
av1_get_crc_value(&x->crc_calculator1, (uint8_t *)pixel_to_hash,
|
||||
sizeof(pixel_to_hash));
|
||||
x->hash_value_buffer[1][0][pos] =
|
||||
av1_get_crc_value(&x->crc_calculator2, (uint8_t *)pixel_to_hash,
|
||||
sizeof(pixel_to_hash));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -429,10 +423,10 @@ void av1_get_block_hash_value(uint8_t *y_src, int stride, int block_size,
|
|||
get_pixels_in_1D_char_array_by_block_2x2(y_src + y_pos * stride + x_pos,
|
||||
stride, pixel_to_hash);
|
||||
assert(pos < AOM_BUFFER_SIZE_FOR_BLOCK_HASH);
|
||||
hash_value_buffer[0][0][pos] = av1_get_crc_value(
|
||||
&crc_calculator1, pixel_to_hash, sizeof(pixel_to_hash));
|
||||
hash_value_buffer[1][0][pos] = av1_get_crc_value(
|
||||
&crc_calculator2, pixel_to_hash, sizeof(pixel_to_hash));
|
||||
x->hash_value_buffer[0][0][pos] = av1_get_crc_value(
|
||||
&x->crc_calculator1, pixel_to_hash, sizeof(pixel_to_hash));
|
||||
x->hash_value_buffer[1][0][pos] = av1_get_crc_value(
|
||||
&x->crc_calculator2, pixel_to_hash, sizeof(pixel_to_hash));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -457,24 +451,24 @@ void av1_get_block_hash_value(uint8_t *y_src, int stride, int block_size,
|
|||
assert(srcPos + src_sub_block_in_width + 1 <
|
||||
AOM_BUFFER_SIZE_FOR_BLOCK_HASH);
|
||||
assert(dst_pos < AOM_BUFFER_SIZE_FOR_BLOCK_HASH);
|
||||
to_hash[0] = hash_value_buffer[0][src_idx][srcPos];
|
||||
to_hash[1] = hash_value_buffer[0][src_idx][srcPos + 1];
|
||||
to_hash[0] = x->hash_value_buffer[0][src_idx][srcPos];
|
||||
to_hash[1] = x->hash_value_buffer[0][src_idx][srcPos + 1];
|
||||
to_hash[2] =
|
||||
hash_value_buffer[0][src_idx][srcPos + src_sub_block_in_width];
|
||||
to_hash[3] =
|
||||
hash_value_buffer[0][src_idx][srcPos + src_sub_block_in_width + 1];
|
||||
x->hash_value_buffer[0][src_idx][srcPos + src_sub_block_in_width];
|
||||
to_hash[3] = x->hash_value_buffer[0][src_idx]
|
||||
[srcPos + src_sub_block_in_width + 1];
|
||||
|
||||
hash_value_buffer[0][dst_idx][dst_pos] = av1_get_crc_value(
|
||||
&crc_calculator1, (uint8_t *)to_hash, sizeof(to_hash));
|
||||
x->hash_value_buffer[0][dst_idx][dst_pos] = av1_get_crc_value(
|
||||
&x->crc_calculator1, (uint8_t *)to_hash, sizeof(to_hash));
|
||||
|
||||
to_hash[0] = hash_value_buffer[1][src_idx][srcPos];
|
||||
to_hash[1] = hash_value_buffer[1][src_idx][srcPos + 1];
|
||||
to_hash[0] = x->hash_value_buffer[1][src_idx][srcPos];
|
||||
to_hash[1] = x->hash_value_buffer[1][src_idx][srcPos + 1];
|
||||
to_hash[2] =
|
||||
hash_value_buffer[1][src_idx][srcPos + src_sub_block_in_width];
|
||||
to_hash[3] =
|
||||
hash_value_buffer[1][src_idx][srcPos + src_sub_block_in_width + 1];
|
||||
hash_value_buffer[1][dst_idx][dst_pos] = av1_get_crc_value(
|
||||
&crc_calculator2, (uint8_t *)to_hash, sizeof(to_hash));
|
||||
x->hash_value_buffer[1][src_idx][srcPos + src_sub_block_in_width];
|
||||
to_hash[3] = x->hash_value_buffer[1][src_idx]
|
||||
[srcPos + src_sub_block_in_width + 1];
|
||||
x->hash_value_buffer[1][dst_idx][dst_pos] = av1_get_crc_value(
|
||||
&x->crc_calculator2, (uint8_t *)to_hash, sizeof(to_hash));
|
||||
dst_pos++;
|
||||
}
|
||||
}
|
||||
|
|
@ -483,8 +477,6 @@ void av1_get_block_hash_value(uint8_t *y_src, int stride, int block_size,
|
|||
sub_block_in_width >>= 1;
|
||||
}
|
||||
|
||||
*hash_value1 = (hash_value_buffer[0][dst_idx][0] & crc_mask) + add_value;
|
||||
*hash_value2 = hash_value_buffer[1][dst_idx][0];
|
||||
*hash_value1 = (x->hash_value_buffer[0][dst_idx][0] & crc_mask) + add_value;
|
||||
*hash_value2 = x->hash_value_buffer[1][dst_idx][0];
|
||||
}
|
||||
|
||||
#undef AOM_BUFFER_SIZE_FOR_BLOCK_HASH
|
||||
|
|
|
|||
16
third_party/aom/av1/encoder/hash_motion.h
vendored
16
third_party/aom/av1/encoder/hash_motion.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_HASH_MOTION_H_
|
||||
#define AV1_ENCODER_HASH_MOTION_H_
|
||||
#ifndef AOM_AV1_ENCODER_HASH_MOTION_H_
|
||||
#define AOM_AV1_ENCODER_HASH_MOTION_H_
|
||||
|
||||
#include "config/aom_config.h"
|
||||
|
||||
|
|
@ -34,7 +34,7 @@ typedef struct _hash_table {
|
|||
Vector **p_lookup_table;
|
||||
} hash_table;
|
||||
|
||||
void av1_hash_table_init(hash_table *p_hash_table);
|
||||
void av1_hash_table_init(hash_table *p_hash_table, struct macroblock *x);
|
||||
void av1_hash_table_destroy(hash_table *p_hash_table);
|
||||
void av1_hash_table_create(hash_table *p_hash_table);
|
||||
int32_t av1_hash_table_count(hash_table *p_hash_table, uint32_t hash_value);
|
||||
|
|
@ -44,13 +44,15 @@ int32_t av1_has_exact_match(hash_table *p_hash_table, uint32_t hash_value1,
|
|||
uint32_t hash_value2);
|
||||
void av1_generate_block_2x2_hash_value(const YV12_BUFFER_CONFIG *picture,
|
||||
uint32_t *pic_block_hash[2],
|
||||
int8_t *pic_block_same_info[3]);
|
||||
int8_t *pic_block_same_info[3],
|
||||
struct macroblock *x);
|
||||
void av1_generate_block_hash_value(const YV12_BUFFER_CONFIG *picture,
|
||||
int block_size,
|
||||
uint32_t *src_pic_block_hash[2],
|
||||
uint32_t *dst_pic_block_hash[2],
|
||||
int8_t *src_pic_block_same_info[3],
|
||||
int8_t *dst_pic_block_same_info[3]);
|
||||
int8_t *dst_pic_block_same_info[3],
|
||||
struct macroblock *x);
|
||||
void av1_add_to_hash_map_by_row_with_precal_data(hash_table *p_hash_table,
|
||||
uint32_t *pic_hash[2],
|
||||
int8_t *pic_is_same,
|
||||
|
|
@ -67,10 +69,10 @@ int av1_hash_is_vertical_perfect(const YV12_BUFFER_CONFIG *picture,
|
|||
int block_size, int x_start, int y_start);
|
||||
void av1_get_block_hash_value(uint8_t *y_src, int stride, int block_size,
|
||||
uint32_t *hash_value1, uint32_t *hash_value2,
|
||||
int use_highbitdepth);
|
||||
int use_highbitdepth, struct macroblock *x);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_HASH_MOTION_H_
|
||||
#endif // AOM_AV1_ENCODER_HASH_MOTION_H_
|
||||
|
|
|
|||
38
third_party/aom/av1/encoder/hybrid_fwd_txfm.c
vendored
38
third_party/aom/av1/encoder/hybrid_fwd_txfm.c
vendored
|
|
@ -121,15 +121,45 @@ static void highbd_fwd_txfm_8x4(const int16_t *src_diff, tran_low_t *coeff,
|
|||
static void highbd_fwd_txfm_8x16(const int16_t *src_diff, tran_low_t *coeff,
|
||||
int diff_stride, TxfmParam *txfm_param) {
|
||||
int32_t *dst_coeff = (int32_t *)coeff;
|
||||
av1_fwd_txfm2d_8x16_c(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
|
||||
txfm_param->bd);
|
||||
const TX_TYPE tx_type = txfm_param->tx_type;
|
||||
const int bd = txfm_param->bd;
|
||||
switch (tx_type) {
|
||||
// use the c version for anything including identity for now
|
||||
case V_DCT:
|
||||
case H_DCT:
|
||||
case V_ADST:
|
||||
case H_ADST:
|
||||
case V_FLIPADST:
|
||||
case H_FLIPADST:
|
||||
case IDTX:
|
||||
av1_fwd_txfm2d_8x16_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
|
||||
break;
|
||||
default:
|
||||
av1_fwd_txfm2d_8x16(src_diff, dst_coeff, diff_stride, tx_type, bd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void highbd_fwd_txfm_16x8(const int16_t *src_diff, tran_low_t *coeff,
|
||||
int diff_stride, TxfmParam *txfm_param) {
|
||||
int32_t *dst_coeff = (int32_t *)coeff;
|
||||
av1_fwd_txfm2d_16x8_c(src_diff, dst_coeff, diff_stride, txfm_param->tx_type,
|
||||
txfm_param->bd);
|
||||
const TX_TYPE tx_type = txfm_param->tx_type;
|
||||
const int bd = txfm_param->bd;
|
||||
switch (tx_type) {
|
||||
// use the c version for anything including identity for now
|
||||
case V_DCT:
|
||||
case H_DCT:
|
||||
case V_ADST:
|
||||
case H_ADST:
|
||||
case V_FLIPADST:
|
||||
case H_FLIPADST:
|
||||
case IDTX:
|
||||
av1_fwd_txfm2d_16x8_c(src_diff, dst_coeff, diff_stride, tx_type, bd);
|
||||
break;
|
||||
default:
|
||||
av1_fwd_txfm2d_16x8(src_diff, dst_coeff, diff_stride, tx_type, bd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void highbd_fwd_txfm_16x32(const int16_t *src_diff, tran_low_t *coeff,
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_HYBRID_FWD_TXFM_H_
|
||||
#define AV1_ENCODER_HYBRID_FWD_TXFM_H_
|
||||
#ifndef AOM_AV1_ENCODER_HYBRID_FWD_TXFM_H_
|
||||
#define AOM_AV1_ENCODER_HYBRID_FWD_TXFM_H_
|
||||
|
||||
#include "config/aom_config.h"
|
||||
|
||||
|
|
@ -28,4 +28,4 @@ void av1_highbd_fwd_txfm(const int16_t *src_diff, tran_low_t *coeff,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_HYBRID_FWD_TXFM_H_
|
||||
#endif // AOM_AV1_ENCODER_HYBRID_FWD_TXFM_H_
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/lookahead.h
vendored
6
third_party/aom/av1/encoder/lookahead.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_LOOKAHEAD_H_
|
||||
#define AV1_ENCODER_LOOKAHEAD_H_
|
||||
#ifndef AOM_AV1_ENCODER_LOOKAHEAD_H_
|
||||
#define AOM_AV1_ENCODER_LOOKAHEAD_H_
|
||||
|
||||
#include "aom_scale/yv12config.h"
|
||||
#include "aom/aom_integer.h"
|
||||
|
|
@ -103,4 +103,4 @@ unsigned int av1_lookahead_depth(struct lookahead_ctx *ctx);
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_LOOKAHEAD_H_
|
||||
#endif // AOM_AV1_ENCODER_LOOKAHEAD_H_
|
||||
|
|
|
|||
7
third_party/aom/av1/encoder/mathutils.h
vendored
7
third_party/aom/av1/encoder/mathutils.h
vendored
|
|
@ -9,6 +9,9 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AOM_AV1_ENCODER_MATHUTILS_H_
|
||||
#define AOM_AV1_ENCODER_MATHUTILS_H_
|
||||
|
||||
#include <memory.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
|
@ -23,7 +26,7 @@ static INLINE int linsolve(int n, double *A, int stride, double *b, double *x) {
|
|||
double c;
|
||||
// Forward elimination
|
||||
for (k = 0; k < n - 1; k++) {
|
||||
// Bring the largest magitude to the diagonal position
|
||||
// Bring the largest magnitude to the diagonal position
|
||||
for (i = n - 1; i > k; i--) {
|
||||
if (fabs(A[(i - 1) * stride + k]) < fabs(A[i * stride + k])) {
|
||||
for (j = 0; j < n; j++) {
|
||||
|
|
@ -352,3 +355,5 @@ static INLINE int SVD(double *U, double *W, double *V, double *matx, int M,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif // AOM_AV1_ENCODER_MATHUTILS_H_
|
||||
|
|
|
|||
7
third_party/aom/av1/encoder/mbgraph.c
vendored
7
third_party/aom/av1/encoder/mbgraph.c
vendored
|
|
@ -17,11 +17,12 @@
|
|||
#include "aom_dsp/aom_dsp_common.h"
|
||||
#include "aom_mem/aom_mem.h"
|
||||
#include "aom_ports/system_state.h"
|
||||
#include "av1/encoder/segmentation.h"
|
||||
#include "av1/encoder/mcomp.h"
|
||||
#include "av1/common/blockd.h"
|
||||
#include "av1/common/reconinter.h"
|
||||
#include "av1/common/reconintra.h"
|
||||
#include "av1/encoder/mcomp.h"
|
||||
#include "av1/encoder/reconinter_enc.h"
|
||||
#include "av1/encoder/segmentation.h"
|
||||
|
||||
static unsigned int do_16x16_motion_iteration(AV1_COMP *cpi, const MV *ref_mv,
|
||||
int mb_row, int mb_col) {
|
||||
|
|
@ -140,7 +141,7 @@ static int find_best_16x16_intra(AV1_COMP *cpi, PREDICTION_MODE *pbest_mode) {
|
|||
|
||||
// calculate SATD for each intra prediction mode;
|
||||
// we're intentionally not doing 4x4, we just want a rough estimate
|
||||
for (mode = DC_PRED; mode <= PAETH_PRED; mode++) {
|
||||
for (mode = INTRA_MODE_START; mode < INTRA_MODE_END; mode++) {
|
||||
unsigned int err;
|
||||
|
||||
xd->mi[0]->mode = mode;
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/mbgraph.h
vendored
6
third_party/aom/av1/encoder/mbgraph.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_MBGRAPH_H_
|
||||
#define AV1_ENCODER_MBGRAPH_H_
|
||||
#ifndef AOM_AV1_ENCODER_MBGRAPH_H_
|
||||
#define AOM_AV1_ENCODER_MBGRAPH_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -38,4 +38,4 @@ void av1_update_mbgraph_stats(struct AV1_COMP *cpi);
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_MBGRAPH_H_
|
||||
#endif // AOM_AV1_ENCODER_MBGRAPH_H_
|
||||
|
|
|
|||
231
third_party/aom/av1/encoder/mcomp.c
vendored
231
third_party/aom/av1/encoder/mcomp.c
vendored
|
|
@ -29,6 +29,7 @@
|
|||
#include "av1/encoder/encodemv.h"
|
||||
#include "av1/encoder/mcomp.h"
|
||||
#include "av1/encoder/rdopt.h"
|
||||
#include "av1/encoder/reconinter_enc.h"
|
||||
|
||||
// #define NEW_DIAMOND_SEARCH
|
||||
|
||||
|
|
@ -219,7 +220,7 @@ static INLINE const uint8_t *pre(const uint8_t *buf, int stride, int r, int c) {
|
|||
thismse = upsampled_pref_error( \
|
||||
xd, cm, mi_row, mi_col, &this_mv, vfp, src_address, src_stride, \
|
||||
pre(y, y_stride, r, c), y_stride, sp(c), sp(r), second_pred, mask, \
|
||||
mask_stride, invert_mask, w, h, &sse); \
|
||||
mask_stride, invert_mask, w, h, &sse, use_accurate_subpel_search); \
|
||||
v = mv_err_cost(&this_mv, ref_mv, mvjcost, mvcost, error_per_bit); \
|
||||
v += thismse; \
|
||||
if (v < besterr) { \
|
||||
|
|
@ -342,19 +343,19 @@ static unsigned int setup_center_error(
|
|||
if (second_pred != NULL) {
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||
DECLARE_ALIGNED(16, uint16_t, comp_pred16[MAX_SB_SQUARE]);
|
||||
uint8_t *comp_pred = CONVERT_TO_BYTEPTR(comp_pred16);
|
||||
if (mask) {
|
||||
aom_highbd_comp_mask_pred(comp_pred16, second_pred, w, h, y + offset,
|
||||
aom_highbd_comp_mask_pred(comp_pred, second_pred, w, h, y + offset,
|
||||
y_stride, mask, mask_stride, invert_mask);
|
||||
} else {
|
||||
if (xd->jcp_param.use_jnt_comp_avg)
|
||||
aom_highbd_jnt_comp_avg_pred(comp_pred16, second_pred, w, h,
|
||||
y + offset, y_stride, &xd->jcp_param);
|
||||
aom_highbd_jnt_comp_avg_pred(comp_pred, second_pred, w, h, y + offset,
|
||||
y_stride, &xd->jcp_param);
|
||||
else
|
||||
aom_highbd_comp_avg_pred(comp_pred16, second_pred, w, h, y + offset,
|
||||
aom_highbd_comp_avg_pred(comp_pred, second_pred, w, h, y + offset,
|
||||
y_stride);
|
||||
}
|
||||
besterr =
|
||||
vfp->vf(CONVERT_TO_BYTEPTR(comp_pred16), w, src, src_stride, sse1);
|
||||
besterr = vfp->vf(comp_pred, w, src, src_stride, sse1);
|
||||
} else {
|
||||
DECLARE_ALIGNED(16, uint8_t, comp_pred[MAX_SB_SQUARE]);
|
||||
if (mask) {
|
||||
|
|
@ -648,51 +649,54 @@ static int upsampled_pref_error(MACROBLOCKD *xd, const AV1_COMMON *const cm,
|
|||
int subpel_x_q3, int subpel_y_q3,
|
||||
const uint8_t *second_pred, const uint8_t *mask,
|
||||
int mask_stride, int invert_mask, int w, int h,
|
||||
unsigned int *sse) {
|
||||
unsigned int *sse, int subpel_search) {
|
||||
unsigned int besterr;
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||
DECLARE_ALIGNED(16, uint16_t, pred16[MAX_SB_SQUARE]);
|
||||
uint8_t *pred8 = CONVERT_TO_BYTEPTR(pred16);
|
||||
if (second_pred != NULL) {
|
||||
if (mask) {
|
||||
aom_highbd_comp_mask_upsampled_pred(
|
||||
xd, cm, mi_row, mi_col, mv, pred16, second_pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride, mask, mask_stride, invert_mask, xd->bd);
|
||||
xd, cm, mi_row, mi_col, mv, pred8, second_pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride, mask, mask_stride, invert_mask, xd->bd,
|
||||
subpel_search);
|
||||
} else {
|
||||
if (xd->jcp_param.use_jnt_comp_avg)
|
||||
aom_highbd_jnt_comp_avg_upsampled_pred(
|
||||
xd, cm, mi_row, mi_col, mv, pred16, second_pred, w, h,
|
||||
subpel_x_q3, subpel_y_q3, y, y_stride, xd->bd, &xd->jcp_param);
|
||||
xd, cm, mi_row, mi_col, mv, pred8, second_pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride, xd->bd, &xd->jcp_param, subpel_search);
|
||||
else
|
||||
aom_highbd_comp_avg_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred16,
|
||||
second_pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride, xd->bd);
|
||||
aom_highbd_comp_avg_upsampled_pred(
|
||||
xd, cm, mi_row, mi_col, mv, pred8, second_pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride, xd->bd, subpel_search);
|
||||
}
|
||||
} else {
|
||||
aom_highbd_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred16, w, h,
|
||||
subpel_x_q3, subpel_y_q3, y, y_stride, xd->bd);
|
||||
aom_highbd_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred8, w, h,
|
||||
subpel_x_q3, subpel_y_q3, y, y_stride, xd->bd,
|
||||
subpel_search);
|
||||
}
|
||||
|
||||
besterr = vfp->vf(CONVERT_TO_BYTEPTR(pred16), w, src, src_stride, sse);
|
||||
besterr = vfp->vf(pred8, w, src, src_stride, sse);
|
||||
} else {
|
||||
DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]);
|
||||
if (second_pred != NULL) {
|
||||
if (mask) {
|
||||
aom_comp_mask_upsampled_pred(
|
||||
xd, cm, mi_row, mi_col, mv, pred, second_pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride, mask, mask_stride, invert_mask);
|
||||
aom_comp_mask_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred,
|
||||
second_pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride, mask,
|
||||
mask_stride, invert_mask, subpel_search);
|
||||
} else {
|
||||
if (xd->jcp_param.use_jnt_comp_avg)
|
||||
aom_jnt_comp_avg_upsampled_pred(
|
||||
xd, cm, mi_row, mi_col, mv, pred, second_pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride, &xd->jcp_param);
|
||||
subpel_y_q3, y, y_stride, &xd->jcp_param, subpel_search);
|
||||
else
|
||||
aom_comp_avg_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred,
|
||||
second_pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride);
|
||||
subpel_y_q3, y, y_stride, subpel_search);
|
||||
}
|
||||
} else {
|
||||
aom_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride);
|
||||
subpel_y_q3, y, y_stride, subpel_search);
|
||||
}
|
||||
|
||||
besterr = vfp->vf(pred, w, src, src_stride, sse);
|
||||
|
|
@ -707,10 +711,11 @@ static unsigned int upsampled_setup_center_error(
|
|||
const int src_stride, const uint8_t *const y, int y_stride,
|
||||
const uint8_t *second_pred, const uint8_t *mask, int mask_stride,
|
||||
int invert_mask, int w, int h, int offset, int *mvjcost, int *mvcost[2],
|
||||
unsigned int *sse1, int *distortion) {
|
||||
unsigned int besterr = upsampled_pref_error(
|
||||
xd, cm, mi_row, mi_col, bestmv, vfp, src, src_stride, y + offset,
|
||||
y_stride, 0, 0, second_pred, mask, mask_stride, invert_mask, w, h, sse1);
|
||||
unsigned int *sse1, int *distortion, int subpel_search) {
|
||||
unsigned int besterr =
|
||||
upsampled_pref_error(xd, cm, mi_row, mi_col, bestmv, vfp, src, src_stride,
|
||||
y + offset, y_stride, 0, 0, second_pred, mask,
|
||||
mask_stride, invert_mask, w, h, sse1, subpel_search);
|
||||
*distortion = besterr;
|
||||
besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
|
||||
return besterr;
|
||||
|
|
@ -781,7 +786,8 @@ int av1_find_best_sub_pixel_tree(
|
|||
besterr = upsampled_setup_center_error(
|
||||
xd, cm, mi_row, mi_col, bestmv, ref_mv, error_per_bit, vfp, src_address,
|
||||
src_stride, y, y_stride, second_pred, mask, mask_stride, invert_mask, w,
|
||||
h, offset, mvjcost, mvcost, sse1, distortion);
|
||||
h, offset, mvjcost, mvcost, sse1, distortion,
|
||||
use_accurate_subpel_search);
|
||||
else
|
||||
besterr = setup_center_error(xd, bestmv, ref_mv, error_per_bit, vfp,
|
||||
src_address, src_stride, y, y_stride,
|
||||
|
|
@ -802,7 +808,8 @@ int av1_find_best_sub_pixel_tree(
|
|||
thismse = upsampled_pref_error(
|
||||
xd, cm, mi_row, mi_col, &this_mv, vfp, src_address, src_stride,
|
||||
pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr), second_pred,
|
||||
mask, mask_stride, invert_mask, w, h, &sse);
|
||||
mask, mask_stride, invert_mask, w, h, &sse,
|
||||
use_accurate_subpel_search);
|
||||
} else {
|
||||
thismse = estimate_upsampled_pref_error(
|
||||
xd, vfp, src_address, src_stride, pre(y, y_stride, tr, tc),
|
||||
|
|
@ -837,7 +844,8 @@ int av1_find_best_sub_pixel_tree(
|
|||
thismse = upsampled_pref_error(
|
||||
xd, cm, mi_row, mi_col, &this_mv, vfp, src_address, src_stride,
|
||||
pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr), second_pred,
|
||||
mask, mask_stride, invert_mask, w, h, &sse);
|
||||
mask, mask_stride, invert_mask, w, h, &sse,
|
||||
use_accurate_subpel_search);
|
||||
} else {
|
||||
thismse = estimate_upsampled_pref_error(
|
||||
xd, vfp, src_address, src_stride, pre(y, y_stride, tr, tc),
|
||||
|
|
@ -929,8 +937,8 @@ unsigned int av1_refine_warped_mv(const AV1_COMP *cpi, MACROBLOCK *const x,
|
|||
int16_t bc = mbmi->mv[0].as_mv.col;
|
||||
int16_t *tr = &mbmi->mv[0].as_mv.row;
|
||||
int16_t *tc = &mbmi->mv[0].as_mv.col;
|
||||
WarpedMotionParams best_wm_params = mbmi->wm_params[0];
|
||||
int best_num_proj_ref = mbmi->num_proj_ref[0];
|
||||
WarpedMotionParams best_wm_params = mbmi->wm_params;
|
||||
int best_num_proj_ref = mbmi->num_proj_ref;
|
||||
unsigned int bestmse;
|
||||
int minc, maxc, minr, maxr;
|
||||
const int start = cm->allow_high_precision_mv ? 0 : 4;
|
||||
|
|
@ -962,18 +970,18 @@ unsigned int av1_refine_warped_mv(const AV1_COMP *cpi, MACROBLOCK *const x,
|
|||
memcpy(pts, pts0, total_samples * 2 * sizeof(*pts0));
|
||||
memcpy(pts_inref, pts_inref0, total_samples * 2 * sizeof(*pts_inref0));
|
||||
if (total_samples > 1)
|
||||
mbmi->num_proj_ref[0] =
|
||||
mbmi->num_proj_ref =
|
||||
selectSamples(&this_mv, pts, pts_inref, total_samples, bsize);
|
||||
|
||||
if (!find_projection(mbmi->num_proj_ref[0], pts, pts_inref, bsize, *tr,
|
||||
*tc, &mbmi->wm_params[0], mi_row, mi_col)) {
|
||||
if (!find_projection(mbmi->num_proj_ref, pts, pts_inref, bsize, *tr,
|
||||
*tc, &mbmi->wm_params, mi_row, mi_col)) {
|
||||
thismse =
|
||||
av1_compute_motion_cost(cpi, x, bsize, mi_row, mi_col, &this_mv);
|
||||
|
||||
if (thismse < bestmse) {
|
||||
best_idx = idx;
|
||||
best_wm_params = mbmi->wm_params[0];
|
||||
best_num_proj_ref = mbmi->num_proj_ref[0];
|
||||
best_wm_params = mbmi->wm_params;
|
||||
best_num_proj_ref = mbmi->num_proj_ref;
|
||||
bestmse = thismse;
|
||||
}
|
||||
}
|
||||
|
|
@ -990,8 +998,8 @@ unsigned int av1_refine_warped_mv(const AV1_COMP *cpi, MACROBLOCK *const x,
|
|||
|
||||
*tr = br;
|
||||
*tc = bc;
|
||||
mbmi->wm_params[0] = best_wm_params;
|
||||
mbmi->num_proj_ref[0] = best_num_proj_ref;
|
||||
mbmi->wm_params = best_wm_params;
|
||||
mbmi->num_proj_ref = best_num_proj_ref;
|
||||
return bestmse;
|
||||
}
|
||||
|
||||
|
|
@ -2013,8 +2021,16 @@ int av1_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range,
|
|||
const uint8_t *mask, int mask_stride,
|
||||
int invert_mask, const MV *center_mv,
|
||||
const uint8_t *second_pred) {
|
||||
const MV neighbors[8] = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 },
|
||||
{ -1, -1 }, { 1, -1 }, { -1, 1 }, { 1, 1 } };
|
||||
static const search_neighbors neighbors[8] = {
|
||||
{ { -1, 0 }, -1 * SEARCH_GRID_STRIDE_8P + 0 },
|
||||
{ { 0, -1 }, 0 * SEARCH_GRID_STRIDE_8P - 1 },
|
||||
{ { 0, 1 }, 0 * SEARCH_GRID_STRIDE_8P + 1 },
|
||||
{ { 1, 0 }, 1 * SEARCH_GRID_STRIDE_8P + 0 },
|
||||
{ { -1, -1 }, -1 * SEARCH_GRID_STRIDE_8P - 1 },
|
||||
{ { 1, -1 }, 1 * SEARCH_GRID_STRIDE_8P - 1 },
|
||||
{ { -1, 1 }, -1 * SEARCH_GRID_STRIDE_8P + 1 },
|
||||
{ { 1, 1 }, 1 * SEARCH_GRID_STRIDE_8P + 1 }
|
||||
};
|
||||
const MACROBLOCKD *const xd = &x->e_mbd;
|
||||
const struct buf_2d *const what = &x->plane[0].src;
|
||||
const struct buf_2d *const in_what = &xd->plane[0].pre[0];
|
||||
|
|
@ -2022,6 +2038,10 @@ int av1_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range,
|
|||
MV *best_mv = &x->best_mv.as_mv;
|
||||
unsigned int best_sad = INT_MAX;
|
||||
int i, j;
|
||||
uint8_t do_refine_search_grid[SEARCH_GRID_STRIDE_8P * SEARCH_GRID_STRIDE_8P] =
|
||||
{ 0 };
|
||||
int grid_center = SEARCH_GRID_CENTER_8P;
|
||||
int grid_coord = grid_center;
|
||||
|
||||
clamp_mv(best_mv, x->mv_limits.col_min, x->mv_limits.col_max,
|
||||
x->mv_limits.row_min, x->mv_limits.row_max);
|
||||
|
|
@ -2043,13 +2063,20 @@ int av1_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range,
|
|||
mvsad_err_cost(x, best_mv, &fcenter_mv, error_per_bit);
|
||||
}
|
||||
|
||||
do_refine_search_grid[grid_coord] = 1;
|
||||
|
||||
for (i = 0; i < search_range; ++i) {
|
||||
int best_site = -1;
|
||||
|
||||
for (j = 0; j < 8; ++j) {
|
||||
const MV mv = { best_mv->row + neighbors[j].row,
|
||||
best_mv->col + neighbors[j].col };
|
||||
grid_coord = grid_center + neighbors[j].coord_offset;
|
||||
if (do_refine_search_grid[grid_coord] == 1) {
|
||||
continue;
|
||||
}
|
||||
const MV mv = { best_mv->row + neighbors[j].coord.row,
|
||||
best_mv->col + neighbors[j].coord.col };
|
||||
|
||||
do_refine_search_grid[grid_coord] = 1;
|
||||
if (is_mv_in(&x->mv_limits, &mv)) {
|
||||
unsigned int sad;
|
||||
if (mask) {
|
||||
|
|
@ -2079,8 +2106,9 @@ int av1_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range,
|
|||
if (best_site == -1) {
|
||||
break;
|
||||
} else {
|
||||
best_mv->row += neighbors[best_site].row;
|
||||
best_mv->col += neighbors[best_site].col;
|
||||
best_mv->row += neighbors[best_site].coord.row;
|
||||
best_mv->col += neighbors[best_site].coord.col;
|
||||
grid_center += neighbors[best_site].coord_offset;
|
||||
}
|
||||
}
|
||||
return best_sad;
|
||||
|
|
@ -2099,11 +2127,11 @@ static int is_exhaustive_allowed(const AV1_COMP *const cpi, MACROBLOCK *x) {
|
|||
}
|
||||
|
||||
int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
|
||||
MV *mvp_full, int step_param, int error_per_bit,
|
||||
MV *mvp_full, int step_param, int method,
|
||||
int run_mesh_search, int error_per_bit,
|
||||
int *cost_list, const MV *ref_mv, int var_max, int rd,
|
||||
int x_pos, int y_pos, int intra) {
|
||||
const SPEED_FEATURES *const sf = &cpi->sf;
|
||||
const SEARCH_METHODS method = sf->mv.search_method;
|
||||
const aom_variance_fn_ptr_t *fn_ptr = &cpi->fn_ptr[bsize];
|
||||
int var = 0;
|
||||
|
||||
|
|
@ -2168,11 +2196,35 @@ int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
|
|||
default: assert(0 && "Invalid search method.");
|
||||
}
|
||||
|
||||
// Should we allow a follow on exhaustive search?
|
||||
if (!run_mesh_search) {
|
||||
if (method == NSTEP) {
|
||||
if (is_exhaustive_allowed(cpi, x)) {
|
||||
int exhuastive_thr = sf->exhaustive_searches_thresh;
|
||||
exhuastive_thr >>=
|
||||
10 - (mi_size_wide_log2[bsize] + mi_size_high_log2[bsize]);
|
||||
// Threshold variance for an exhaustive full search.
|
||||
if (var > exhuastive_thr) run_mesh_search = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (run_mesh_search) {
|
||||
int var_ex;
|
||||
MV tmp_mv_ex;
|
||||
var_ex = full_pixel_exhaustive(cpi, x, &x->best_mv.as_mv, error_per_bit,
|
||||
cost_list, fn_ptr, ref_mv, &tmp_mv_ex);
|
||||
if (var_ex < var) {
|
||||
var = var_ex;
|
||||
x->best_mv.as_mv = tmp_mv_ex;
|
||||
}
|
||||
}
|
||||
|
||||
if (method != NSTEP && rd && var < var_max)
|
||||
var = av1_get_mvpred_var(x, &x->best_mv.as_mv, ref_mv, fn_ptr, 1);
|
||||
|
||||
do {
|
||||
if (!av1_use_hash_me(&cpi->common)) break;
|
||||
if (!intra || !av1_use_hash_me(&cpi->common)) break;
|
||||
|
||||
// already single ME
|
||||
// get block size and original buffer of current block
|
||||
|
|
@ -2195,7 +2247,7 @@ int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
|
|||
|
||||
av1_get_block_hash_value(
|
||||
what, what_stride, block_width, &hash_value1, &hash_value2,
|
||||
x->e_mbd.cur_buf->flags & YV12_FLAG_HIGHBITDEPTH);
|
||||
x->e_mbd.cur_buf->flags & YV12_FLAG_HIGHBITDEPTH, x);
|
||||
|
||||
const int count = av1_hash_table_count(ref_frame_hash, hash_value1);
|
||||
// for intra, at lest one matching can be found, itself.
|
||||
|
|
@ -2279,7 +2331,8 @@ int av1_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bsize,
|
|||
MV this_mv = { r, c }; \
|
||||
thismse = upsampled_obmc_pref_error(xd, cm, mi_row, mi_col, &this_mv, \
|
||||
mask, vfp, z, pre(y, y_stride, r, c), \
|
||||
y_stride, sp(c), sp(r), w, h, &sse); \
|
||||
y_stride, sp(c), sp(r), w, h, &sse, \
|
||||
use_accurate_subpel_search); \
|
||||
if ((v = MVC(r, c) + thismse) < besterr) { \
|
||||
besterr = v; \
|
||||
br = r; \
|
||||
|
|
@ -2307,18 +2360,20 @@ static int upsampled_obmc_pref_error(
|
|||
MACROBLOCKD *xd, const AV1_COMMON *const cm, int mi_row, int mi_col,
|
||||
const MV *const mv, const int32_t *mask, const aom_variance_fn_ptr_t *vfp,
|
||||
const int32_t *const wsrc, const uint8_t *const y, int y_stride,
|
||||
int subpel_x_q3, int subpel_y_q3, int w, int h, unsigned int *sse) {
|
||||
int subpel_x_q3, int subpel_y_q3, int w, int h, unsigned int *sse,
|
||||
int subpel_search) {
|
||||
unsigned int besterr;
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||
DECLARE_ALIGNED(16, uint16_t, pred16[MAX_SB_SQUARE]);
|
||||
aom_highbd_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred16, w, h,
|
||||
subpel_x_q3, subpel_y_q3, y, y_stride, xd->bd);
|
||||
|
||||
besterr = vfp->ovf(CONVERT_TO_BYTEPTR(pred16), w, wsrc, mask, sse);
|
||||
DECLARE_ALIGNED(16, uint8_t, pred[2 * MAX_SB_SQUARE]);
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||
uint8_t *pred8 = CONVERT_TO_BYTEPTR(pred);
|
||||
aom_highbd_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred8, w, h,
|
||||
subpel_x_q3, subpel_y_q3, y, y_stride, xd->bd,
|
||||
subpel_search);
|
||||
besterr = vfp->ovf(pred8, w, wsrc, mask, sse);
|
||||
} else {
|
||||
DECLARE_ALIGNED(16, uint8_t, pred[MAX_SB_SQUARE]);
|
||||
aom_upsampled_pred(xd, cm, mi_row, mi_col, mv, pred, w, h, subpel_x_q3,
|
||||
subpel_y_q3, y, y_stride);
|
||||
subpel_y_q3, y, y_stride, subpel_search);
|
||||
|
||||
besterr = vfp->ovf(pred, w, wsrc, mask, sse);
|
||||
}
|
||||
|
|
@ -2330,10 +2385,11 @@ static unsigned int upsampled_setup_obmc_center_error(
|
|||
const int32_t *mask, const MV *bestmv, const MV *ref_mv, int error_per_bit,
|
||||
const aom_variance_fn_ptr_t *vfp, const int32_t *const wsrc,
|
||||
const uint8_t *const y, int y_stride, int w, int h, int offset,
|
||||
int *mvjcost, int *mvcost[2], unsigned int *sse1, int *distortion) {
|
||||
unsigned int besterr =
|
||||
upsampled_obmc_pref_error(xd, cm, mi_row, mi_col, bestmv, mask, vfp, wsrc,
|
||||
y + offset, y_stride, 0, 0, w, h, sse1);
|
||||
int *mvjcost, int *mvcost[2], unsigned int *sse1, int *distortion,
|
||||
int subpel_search) {
|
||||
unsigned int besterr = upsampled_obmc_pref_error(
|
||||
xd, cm, mi_row, mi_col, bestmv, mask, vfp, wsrc, y + offset, y_stride, 0,
|
||||
0, w, h, sse1, subpel_search);
|
||||
*distortion = besterr;
|
||||
besterr += mv_err_cost(bestmv, ref_mv, mvjcost, mvcost, error_per_bit);
|
||||
return besterr;
|
||||
|
|
@ -2388,11 +2444,12 @@ int av1_find_best_obmc_sub_pixel_tree_up(
|
|||
|
||||
bestmv->row *= 8;
|
||||
bestmv->col *= 8;
|
||||
// use_accurate_subpel_search can be 0 or 1
|
||||
// use_accurate_subpel_search can be 0 or 1 or 2
|
||||
if (use_accurate_subpel_search)
|
||||
besterr = upsampled_setup_obmc_center_error(
|
||||
xd, cm, mi_row, mi_col, mask, bestmv, ref_mv, error_per_bit, vfp, z, y,
|
||||
y_stride, w, h, offset, mvjcost, mvcost, sse1, distortion);
|
||||
y_stride, w, h, offset, mvjcost, mvcost, sse1, distortion,
|
||||
use_accurate_subpel_search);
|
||||
else
|
||||
besterr = setup_obmc_center_error(mask, bestmv, ref_mv, error_per_bit, vfp,
|
||||
z, y, y_stride, offset, mvjcost, mvcost,
|
||||
|
|
@ -2408,7 +2465,8 @@ int av1_find_best_obmc_sub_pixel_tree_up(
|
|||
if (use_accurate_subpel_search) {
|
||||
thismse = upsampled_obmc_pref_error(
|
||||
xd, cm, mi_row, mi_col, &this_mv, mask, vfp, src_address,
|
||||
pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr), w, h, &sse);
|
||||
pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr), w, h, &sse,
|
||||
use_accurate_subpel_search);
|
||||
} else {
|
||||
thismse = vfp->osvf(pre(y, y_stride, tr, tc), y_stride, sp(tc),
|
||||
sp(tr), src_address, mask, &sse);
|
||||
|
|
@ -2439,7 +2497,8 @@ int av1_find_best_obmc_sub_pixel_tree_up(
|
|||
if (use_accurate_subpel_search) {
|
||||
thismse = upsampled_obmc_pref_error(
|
||||
xd, cm, mi_row, mi_col, &this_mv, mask, vfp, src_address,
|
||||
pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr), w, h, &sse);
|
||||
pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr), w, h, &sse,
|
||||
use_accurate_subpel_search);
|
||||
} else {
|
||||
thismse = vfp->osvf(pre(y, y_stride, tr, tc), y_stride, sp(tc), sp(tr),
|
||||
src_address, mask, &sse);
|
||||
|
|
@ -2643,11 +2702,12 @@ int obmc_diamond_search_sad(const MACROBLOCK *x, const search_site_config *cfg,
|
|||
return best_sad;
|
||||
}
|
||||
|
||||
int av1_obmc_full_pixel_diamond(const AV1_COMP *cpi, MACROBLOCK *x,
|
||||
MV *mvp_full, int step_param, int sadpb,
|
||||
int further_steps, int do_refine,
|
||||
const aom_variance_fn_ptr_t *fn_ptr,
|
||||
const MV *ref_mv, MV *dst_mv, int is_second) {
|
||||
static int obmc_full_pixel_diamond(const AV1_COMP *cpi, MACROBLOCK *x,
|
||||
MV *mvp_full, int step_param, int sadpb,
|
||||
int further_steps, int do_refine,
|
||||
const aom_variance_fn_ptr_t *fn_ptr,
|
||||
const MV *ref_mv, MV *dst_mv,
|
||||
int is_second) {
|
||||
const int32_t *wsrc = x->wsrc_buf;
|
||||
const int32_t *mask = x->mask_buf;
|
||||
MV temp_mv;
|
||||
|
|
@ -2704,6 +2764,31 @@ int av1_obmc_full_pixel_diamond(const AV1_COMP *cpi, MACROBLOCK *x,
|
|||
return bestsme;
|
||||
}
|
||||
|
||||
int av1_obmc_full_pixel_search(const AV1_COMP *cpi, MACROBLOCK *x, MV *mvp_full,
|
||||
int step_param, int sadpb, int further_steps,
|
||||
int do_refine,
|
||||
const aom_variance_fn_ptr_t *fn_ptr,
|
||||
const MV *ref_mv, MV *dst_mv, int is_second) {
|
||||
if (cpi->sf.obmc_full_pixel_search_level == 0) {
|
||||
return obmc_full_pixel_diamond(cpi, x, mvp_full, step_param, sadpb,
|
||||
further_steps, do_refine, fn_ptr, ref_mv,
|
||||
dst_mv, is_second);
|
||||
} else {
|
||||
const int32_t *wsrc = x->wsrc_buf;
|
||||
const int32_t *mask = x->mask_buf;
|
||||
const int search_range = 8;
|
||||
*dst_mv = *mvp_full;
|
||||
clamp_mv(dst_mv, x->mv_limits.col_min, x->mv_limits.col_max,
|
||||
x->mv_limits.row_min, x->mv_limits.row_max);
|
||||
int thissme = obmc_refining_search_sad(
|
||||
x, wsrc, mask, dst_mv, sadpb, search_range, fn_ptr, ref_mv, is_second);
|
||||
if (thissme < INT_MAX)
|
||||
thissme = get_obmc_mvpred_var(x, wsrc, mask, dst_mv, ref_mv, fn_ptr, 1,
|
||||
is_second);
|
||||
return thissme;
|
||||
}
|
||||
}
|
||||
|
||||
// Note(yunqingwang): The following 2 functions are only used in the motion
|
||||
// vector unit test, which return extreme motion vectors allowed by the MV
|
||||
// limits.
|
||||
|
|
|
|||
31
third_party/aom/av1/encoder/mcomp.h
vendored
31
third_party/aom/av1/encoder/mcomp.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_MCOMP_H_
|
||||
#define AV1_ENCODER_MCOMP_H_
|
||||
#ifndef AOM_AV1_ENCODER_MCOMP_H_
|
||||
#define AOM_AV1_ENCODER_MCOMP_H_
|
||||
|
||||
#include "av1/encoder/block.h"
|
||||
#include "aom_dsp/variance.h"
|
||||
|
|
@ -31,6 +31,11 @@ extern "C" {
|
|||
// for Block_16x16
|
||||
#define BORDER_MV_PIXELS_B16 (16 + AOM_INTERP_EXTEND)
|
||||
|
||||
#define SEARCH_RANGE_8P 3
|
||||
#define SEARCH_GRID_STRIDE_8P (2 * SEARCH_RANGE_8P + 1)
|
||||
#define SEARCH_GRID_CENTER_8P \
|
||||
(SEARCH_RANGE_8P * SEARCH_GRID_STRIDE_8P + SEARCH_RANGE_8P)
|
||||
|
||||
// motion search site
|
||||
typedef struct search_site {
|
||||
MV mv;
|
||||
|
|
@ -43,6 +48,11 @@ typedef struct search_site_config {
|
|||
int searches_per_step;
|
||||
} search_site_config;
|
||||
|
||||
typedef struct {
|
||||
MV coord;
|
||||
int coord_offset;
|
||||
} search_neighbors;
|
||||
|
||||
void av1_init_dsmotion_compensation(search_site_config *cfg, int stride);
|
||||
void av1_init3smotion_compensation(search_site_config *cfg, int stride);
|
||||
|
||||
|
|
@ -120,14 +130,15 @@ int av1_refining_search_8p_c(MACROBLOCK *x, int error_per_bit, int search_range,
|
|||
|
||||
int av1_full_pixel_search(const struct AV1_COMP *cpi, MACROBLOCK *x,
|
||||
BLOCK_SIZE bsize, MV *mvp_full, int step_param,
|
||||
int error_per_bit, int *cost_list, const MV *ref_mv,
|
||||
int var_max, int rd, int x_pos, int y_pos, int intra);
|
||||
int method, int run_mesh_search, int error_per_bit,
|
||||
int *cost_list, const MV *ref_mv, int var_max, int rd,
|
||||
int x_pos, int y_pos, int intra);
|
||||
|
||||
int av1_obmc_full_pixel_diamond(const struct AV1_COMP *cpi, MACROBLOCK *x,
|
||||
MV *mvp_full, int step_param, int sadpb,
|
||||
int further_steps, int do_refine,
|
||||
const aom_variance_fn_ptr_t *fn_ptr,
|
||||
const MV *ref_mv, MV *dst_mv, int is_second);
|
||||
int av1_obmc_full_pixel_search(const struct AV1_COMP *cpi, MACROBLOCK *x,
|
||||
MV *mvp_full, int step_param, int sadpb,
|
||||
int further_steps, int do_refine,
|
||||
const aom_variance_fn_ptr_t *fn_ptr,
|
||||
const MV *ref_mv, MV *dst_mv, int is_second);
|
||||
int av1_find_best_obmc_sub_pixel_tree_up(
|
||||
MACROBLOCK *x, const AV1_COMMON *const cm, int mi_row, int mi_col,
|
||||
MV *bestmv, const MV *ref_mv, int allow_hp, int error_per_bit,
|
||||
|
|
@ -147,4 +158,4 @@ unsigned int av1_refine_warped_mv(const struct AV1_COMP *cpi,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_MCOMP_H_
|
||||
#endif // AOM_AV1_ENCODER_MCOMP_H_
|
||||
|
|
|
|||
16
third_party/aom/av1/encoder/ml.c
vendored
16
third_party/aom/av1/encoder/ml.c
vendored
|
|
@ -10,7 +10,9 @@
|
|||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "aom_dsp/aom_dsp_common.h"
|
||||
#include "av1/encoder/ml.h"
|
||||
|
||||
void av1_nn_predict(const float *features, const NN_CONFIG *nn_config,
|
||||
|
|
@ -55,3 +57,17 @@ void av1_nn_predict(const float *features, const NN_CONFIG *nn_config,
|
|||
weights += num_input_nodes;
|
||||
}
|
||||
}
|
||||
|
||||
void av1_nn_softmax(const float *input, float *output, int n) {
|
||||
// Softmax function is invariant to adding the same constant
|
||||
// to all input values, so we subtract the maximum input to avoid
|
||||
// possible overflow.
|
||||
float max_inp = input[0];
|
||||
for (int i = 1; i < n; i++) max_inp = AOMMAX(max_inp, input[i]);
|
||||
float sum_out = 0.0f;
|
||||
for (int i = 0; i < n; i++) {
|
||||
output[i] = (float)exp(input[i] - max_inp);
|
||||
sum_out += output[i];
|
||||
}
|
||||
for (int i = 0; i < n; i++) output[i] /= sum_out;
|
||||
}
|
||||
|
|
|
|||
11
third_party/aom/av1/encoder/ml.h
vendored
11
third_party/aom/av1/encoder/ml.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_ML_H_
|
||||
#define AV1_ENCODER_ML_H_
|
||||
#ifndef AOM_AV1_ENCODER_ML_H_
|
||||
#define AOM_AV1_ENCODER_ML_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -37,8 +37,13 @@ typedef struct {
|
|||
void av1_nn_predict(const float *features, const NN_CONFIG *nn_config,
|
||||
float *output);
|
||||
|
||||
// Applies the softmax normalization function to the input
|
||||
// to get a valid probability distribution in the output:
|
||||
// output[i] = exp(input[i]) / sum_{k \in [0,n)}(exp(input[k]))
|
||||
void av1_nn_softmax(const float *input, float *output, int n);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_RD_H_
|
||||
#endif // AOM_AV1_ENCODER_ML_H_
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/palette.h
vendored
6
third_party/aom/av1/encoder/palette.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_PALETTE_H_
|
||||
#define AV1_ENCODER_PALETTE_H_
|
||||
#ifndef AOM_AV1_ENCODER_PALETTE_H_
|
||||
#define AOM_AV1_ENCODER_PALETTE_H_
|
||||
|
||||
#include "av1/common/blockd.h"
|
||||
|
||||
|
|
@ -93,4 +93,4 @@ int av1_palette_color_cost_uv(const PALETTE_MODE_INFO *const pmi,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif /* AV1_ENCODER_PALETTE_H_ */
|
||||
#endif // AOM_AV1_ENCODER_PALETTE_H_
|
||||
|
|
|
|||
1441
third_party/aom/av1/encoder/partition_model_weights.h
vendored
1441
third_party/aom/av1/encoder/partition_model_weights.h
vendored
File diff suppressed because it is too large
Load diff
3
third_party/aom/av1/encoder/picklpf.c
vendored
3
third_party/aom/av1/encoder/picklpf.c
vendored
|
|
@ -70,7 +70,7 @@ static int64_t try_filter_frame(const YV12_BUFFER_CONFIG *sd,
|
|||
// TODO(any): please enable multi-thread and remove the flag when loop
|
||||
// filter mask is compatible with multi-thread.
|
||||
#if LOOP_FILTER_BITMASK
|
||||
av1_loop_filter_frame(cm->frame_to_show, cm, &cpi->td.mb.e_mbd, plane,
|
||||
av1_loop_filter_frame(cm->frame_to_show, cm, &cpi->td.mb.e_mbd, 0, plane,
|
||||
plane + 1, partial_frame);
|
||||
#else
|
||||
if (cpi->num_workers > 1)
|
||||
|
|
@ -193,6 +193,7 @@ void av1_pick_filter_level(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi,
|
|||
(void)sd;
|
||||
|
||||
lf->sharpness_level = 0;
|
||||
cpi->td.mb.rdmult = cpi->rd.RDMULT;
|
||||
|
||||
if (method == LPF_PICK_MINIMAL_LPF) {
|
||||
lf->filter_level[0] = 0;
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/picklpf.h
vendored
6
third_party/aom/av1/encoder/picklpf.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_PICKLPF_H_
|
||||
#define AV1_ENCODER_PICKLPF_H_
|
||||
#ifndef AOM_AV1_ENCODER_PICKLPF_H_
|
||||
#define AOM_AV1_ENCODER_PICKLPF_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -27,4 +27,4 @@ void av1_pick_filter_level(const struct yv12_buffer_config *sd,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_PICKLPF_H_
|
||||
#endif // AOM_AV1_ENCODER_PICKLPF_H_
|
||||
|
|
|
|||
128
third_party/aom/av1/encoder/pickrst.c
vendored
128
third_party/aom/av1/encoder/pickrst.c
vendored
|
|
@ -15,6 +15,7 @@
|
|||
#include <math.h>
|
||||
|
||||
#include "config/aom_scale_rtcd.h"
|
||||
#include "config/av1_rtcd.h"
|
||||
|
||||
#include "aom_dsp/aom_dsp_common.h"
|
||||
#include "aom_dsp/binary_codes_writer.h"
|
||||
|
|
@ -22,7 +23,6 @@
|
|||
#include "aom_mem/aom_mem.h"
|
||||
#include "aom_ports/mem.h"
|
||||
#include "aom_ports/system_state.h"
|
||||
|
||||
#include "av1/common/onyxc_int.h"
|
||||
#include "av1/common/quant_common.h"
|
||||
#include "av1/common/restoration.h"
|
||||
|
|
@ -181,6 +181,77 @@ static int64_t try_restoration_unit(const RestSearchCtxt *rsc,
|
|||
return sse_restoration_unit(limits, rsc->src, rsc->dst, plane, highbd);
|
||||
}
|
||||
|
||||
int64_t av1_lowbd_pixel_proj_error_c(const uint8_t *src8, int width, int height,
|
||||
int src_stride, const uint8_t *dat8,
|
||||
int dat_stride, int32_t *flt0,
|
||||
int flt0_stride, int32_t *flt1,
|
||||
int flt1_stride, int xq[2],
|
||||
const sgr_params_type *params) {
|
||||
int i, j;
|
||||
const uint8_t *src = src8;
|
||||
const uint8_t *dat = dat8;
|
||||
int64_t err = 0;
|
||||
if (params->r[0] > 0 && params->r[1] > 0) {
|
||||
for (i = 0; i < height; ++i) {
|
||||
for (j = 0; j < width; ++j) {
|
||||
assert(flt1[j] < (1 << 15) && flt1[j] > -(1 << 15));
|
||||
assert(flt0[j] < (1 << 15) && flt0[j] > -(1 << 15));
|
||||
const int32_t u = (int32_t)(dat[j] << SGRPROJ_RST_BITS);
|
||||
int32_t v = u << SGRPROJ_PRJ_BITS;
|
||||
v += xq[0] * (flt0[j] - u) + xq[1] * (flt1[j] - u);
|
||||
const int32_t e =
|
||||
ROUND_POWER_OF_TWO(v, SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS) - src[j];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
flt0 += flt0_stride;
|
||||
flt1 += flt1_stride;
|
||||
}
|
||||
} else if (params->r[0] > 0) {
|
||||
for (i = 0; i < height; ++i) {
|
||||
for (j = 0; j < width; ++j) {
|
||||
assert(flt0[j] < (1 << 15) && flt0[j] > -(1 << 15));
|
||||
const int32_t u = (int32_t)(dat[j] << SGRPROJ_RST_BITS);
|
||||
int32_t v = u << SGRPROJ_PRJ_BITS;
|
||||
v += xq[0] * (flt0[j] - u);
|
||||
const int32_t e =
|
||||
ROUND_POWER_OF_TWO(v, SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS) - src[j];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
flt0 += flt0_stride;
|
||||
}
|
||||
} else if (params->r[1] > 0) {
|
||||
for (i = 0; i < height; ++i) {
|
||||
for (j = 0; j < width; ++j) {
|
||||
assert(flt1[j] < (1 << 15) && flt1[j] > -(1 << 15));
|
||||
const int32_t u = (int32_t)(dat[j] << SGRPROJ_RST_BITS);
|
||||
int32_t v = u << SGRPROJ_PRJ_BITS;
|
||||
v += xq[1] * (flt1[j] - u);
|
||||
const int32_t e =
|
||||
ROUND_POWER_OF_TWO(v, SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS) - src[j];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
flt1 += flt1_stride;
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < height; ++i) {
|
||||
for (j = 0; j < width; ++j) {
|
||||
const int32_t e = (int32_t)(dat[j]) - src[j];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static int64_t get_pixel_proj_error(const uint8_t *src8, int width, int height,
|
||||
int src_stride, const uint8_t *dat8,
|
||||
int dat_stride, int use_highbitdepth,
|
||||
|
|
@ -192,21 +263,9 @@ static int64_t get_pixel_proj_error(const uint8_t *src8, int width, int height,
|
|||
int xq[2];
|
||||
decode_xq(xqd, xq, params);
|
||||
if (!use_highbitdepth) {
|
||||
const uint8_t *src = src8;
|
||||
const uint8_t *dat = dat8;
|
||||
for (i = 0; i < height; ++i) {
|
||||
for (j = 0; j < width; ++j) {
|
||||
const int32_t u =
|
||||
(int32_t)(dat[i * dat_stride + j] << SGRPROJ_RST_BITS);
|
||||
int32_t v = u << SGRPROJ_PRJ_BITS;
|
||||
if (params->r[0] > 0) v += xq[0] * (flt0[i * flt0_stride + j] - u);
|
||||
if (params->r[1] > 0) v += xq[1] * (flt1[i * flt1_stride + j] - u);
|
||||
const int32_t e =
|
||||
ROUND_POWER_OF_TWO(v, SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS) -
|
||||
src[i * src_stride + j];
|
||||
err += e * e;
|
||||
}
|
||||
}
|
||||
err = av1_lowbd_pixel_proj_error(src8, width, height, src_stride, dat8,
|
||||
dat_stride, flt0, flt0_stride, flt1,
|
||||
flt1_stride, xq, params);
|
||||
} else {
|
||||
const uint16_t *src = CONVERT_TO_SHORTPTR(src8);
|
||||
const uint16_t *dat = CONVERT_TO_SHORTPTR(dat8);
|
||||
|
|
@ -463,9 +522,11 @@ static void apply_sgr(int sgr_params_idx, const uint8_t *dat8, int width,
|
|||
// Iterate over the stripe in blocks of width pu_width
|
||||
for (int j = 0; j < width; j += pu_width) {
|
||||
const int w = AOMMIN(pu_width, width - j);
|
||||
av1_selfguided_restoration(dat8_row + j, w, h, dat_stride, flt0_row + j,
|
||||
flt1_row + j, flt_stride, sgr_params_idx,
|
||||
bit_depth, use_highbd);
|
||||
const int ret = av1_selfguided_restoration(
|
||||
dat8_row + j, w, h, dat_stride, flt0_row + j, flt1_row + j,
|
||||
flt_stride, sgr_params_idx, bit_depth, use_highbd);
|
||||
(void)ret;
|
||||
assert(!ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -588,22 +649,9 @@ static void search_sgrproj(const RestorationTileLimits *limits,
|
|||
if (cost_sgr < cost_none) rsc->sgrproj = rusi->sgrproj;
|
||||
}
|
||||
|
||||
static double find_average(const uint8_t *src, int h_start, int h_end,
|
||||
int v_start, int v_end, int stride) {
|
||||
uint64_t sum = 0;
|
||||
double avg = 0;
|
||||
int i, j;
|
||||
aom_clear_system_state();
|
||||
for (i = v_start; i < v_end; i++)
|
||||
for (j = h_start; j < h_end; j++) sum += src[i * stride + j];
|
||||
avg = (double)sum / ((v_end - v_start) * (h_end - h_start));
|
||||
return avg;
|
||||
}
|
||||
|
||||
static void compute_stats(int wiener_win, const uint8_t *dgd,
|
||||
const uint8_t *src, int h_start, int h_end,
|
||||
int v_start, int v_end, int dgd_stride,
|
||||
int src_stride, double *M, double *H) {
|
||||
void av1_compute_stats_c(int wiener_win, const uint8_t *dgd, const uint8_t *src,
|
||||
int h_start, int h_end, int v_start, int v_end,
|
||||
int dgd_stride, int src_stride, double *M, double *H) {
|
||||
int i, j, k, l;
|
||||
double Y[WIENER_WIN2];
|
||||
const int wiener_win2 = wiener_win * wiener_win;
|
||||
|
|
@ -626,8 +674,7 @@ static void compute_stats(int wiener_win, const uint8_t *dgd,
|
|||
assert(idx == wiener_win2);
|
||||
for (k = 0; k < wiener_win2; ++k) {
|
||||
M[k] += Y[k] * X;
|
||||
H[k * wiener_win2 + k] += Y[k] * Y[k];
|
||||
for (l = k + 1; l < wiener_win2; ++l) {
|
||||
for (l = k; l < wiener_win2; ++l) {
|
||||
// H is a symmetric matrix, so we only need to fill out the upper
|
||||
// triangle here. We can copy it down to the lower triangle outside
|
||||
// the (i, j) loops.
|
||||
|
|
@ -1073,9 +1120,9 @@ static void search_wiener(const RestorationTileLimits *limits,
|
|||
limits->h_start, limits->h_end, limits->v_start,
|
||||
limits->v_end, rsc->dgd_stride, rsc->src_stride, M, H);
|
||||
} else {
|
||||
compute_stats(wiener_win, rsc->dgd_buffer, rsc->src_buffer, limits->h_start,
|
||||
limits->h_end, limits->v_start, limits->v_end,
|
||||
rsc->dgd_stride, rsc->src_stride, M, H);
|
||||
av1_compute_stats(wiener_win, rsc->dgd_buffer, rsc->src_buffer,
|
||||
limits->h_start, limits->h_end, limits->v_start,
|
||||
limits->v_end, rsc->dgd_stride, rsc->src_stride, M, H);
|
||||
}
|
||||
|
||||
const MACROBLOCK *const x = rsc->x;
|
||||
|
|
@ -1266,6 +1313,7 @@ void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *src, AV1_COMP *cpi) {
|
|||
// problem, as these elements are ignored later, but in order to quiet
|
||||
// Valgrind's warnings we initialise the array below.
|
||||
memset(rusi, 0, sizeof(*rusi) * ntiles[0]);
|
||||
cpi->td.mb.rdmult = cpi->rd.RDMULT;
|
||||
|
||||
RestSearchCtxt rsc;
|
||||
const int plane_start = AOM_PLANE_Y;
|
||||
|
|
|
|||
23
third_party/aom/av1/encoder/pickrst.h
vendored
23
third_party/aom/av1/encoder/pickrst.h
vendored
|
|
@ -8,22 +8,39 @@
|
|||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
#ifndef AV1_ENCODER_PICKRST_H_
|
||||
#define AV1_ENCODER_PICKRST_H_
|
||||
#ifndef AOM_AV1_ENCODER_PICKRST_H_
|
||||
#define AOM_AV1_ENCODER_PICKRST_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "av1/encoder/encoder.h"
|
||||
#include "aom_ports/system_state.h"
|
||||
|
||||
struct yv12_buffer_config;
|
||||
struct AV1_COMP;
|
||||
|
||||
static const uint8_t g_shuffle_stats_data[16] = {
|
||||
0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8,
|
||||
};
|
||||
|
||||
static INLINE double find_average(const uint8_t *src, int h_start, int h_end,
|
||||
int v_start, int v_end, int stride) {
|
||||
uint64_t sum = 0;
|
||||
double avg = 0;
|
||||
int i, j;
|
||||
aom_clear_system_state();
|
||||
for (i = v_start; i < v_end; i++)
|
||||
for (j = h_start; j < h_end; j++) sum += src[i * stride + j];
|
||||
avg = (double)sum / ((v_end - v_start) * (h_end - h_start));
|
||||
return avg;
|
||||
}
|
||||
|
||||
void av1_pick_filter_restoration(const YV12_BUFFER_CONFIG *sd, AV1_COMP *cpi);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_PICKRST_H_
|
||||
#endif // AOM_AV1_ENCODER_PICKRST_H_
|
||||
|
|
|
|||
183
third_party/aom/av1/encoder/pustats.h
vendored
183
third_party/aom/av1/encoder/pustats.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_PUSTATS_H_
|
||||
#define AV1_ENCODER_PUSTATS_H_
|
||||
#ifndef AOM_AV1_ENCODER_PUSTATS_H_
|
||||
#define AOM_AV1_ENCODER_PUSTATS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -18,83 +18,78 @@ extern "C" {
|
|||
|
||||
#include "av1/encoder/ml.h"
|
||||
|
||||
#define NUM_FEATURES 11
|
||||
#define NUM_FEATURES_PUSTATS 8
|
||||
#define NUM_HIDDEN_LAYERS 2
|
||||
#define HIDDEN_LAYERS_0_NODES 12
|
||||
#define HIDDEN_LAYERS_1_NODES 10
|
||||
#define LOGITS_NODES 1
|
||||
|
||||
static const float
|
||||
av1_pustats_rate_hiddenlayer_0_kernel[NUM_FEATURES *
|
||||
av1_pustats_rate_hiddenlayer_0_kernel[NUM_FEATURES_PUSTATS *
|
||||
HIDDEN_LAYERS_0_NODES] = {
|
||||
21.5067f, 22.6709f, 0.0049f, 0.9288f, -0.0100f, 0.0060f, -0.0071f,
|
||||
-0.0085f, 0.0348f, -0.1273f, 10.1154f, 6.3405f, 7.8589f, -0.0652f,
|
||||
-4.6352f, 0.0445f, -3.2748f, 0.1025f, -0.0385f, -0.4505f, 1.1320f,
|
||||
3.2634f, 23.2420f, -7.9056f, 0.0522f, -18.1555f, 0.0977f, 0.1155f,
|
||||
-0.0138f, 0.0267f, -0.3992f, 0.2735f, 22.8063f, 35.1043f, 3.8140f,
|
||||
-0.0295f, 0.0771f, -0.6938f, 0.0302f, -0.0266f, 0.0989f, -0.0794f,
|
||||
0.2981f, 33.3333f, -24.1150f, 1.4986f, -0.0975f, -15.3938f, -0.0858f,
|
||||
-0.0845f, -0.0869f, -0.0858f, 0.3542f, 0.0155f, -18.2629f, 9.6688f,
|
||||
-11.9643f, -0.2904f, -5.3026f, -0.1011f, -0.1202f, 0.0127f, -0.0269f,
|
||||
0.3434f, 0.0595f, 16.6800f, 41.4730f, 6.9269f, -0.0512f, -1.4540f,
|
||||
0.0468f, 0.0077f, 0.0983f, 0.1265f, -0.5234f, 0.9477f, 36.6470f,
|
||||
-0.4838f, -0.2269f, -0.1143f, -0.3907f, -0.5005f, -0.0179f, -0.1057f,
|
||||
0.1233f, -0.4412f, -0.0474f, 0.1140f, -21.6813f, -0.9077f, -0.0078f,
|
||||
-3.3306f, 0.0417f, 0.0412f, 0.0427f, 0.0418f, -0.1699f, 0.0072f,
|
||||
-22.3335f, 16.1203f, -10.1220f, -0.0019f, 0.0005f, -0.0054f, -0.0155f,
|
||||
-0.0302f, -0.0379f, 0.1276f, 0.1568f, 21.6175f, 12.2919f, 11.0327f,
|
||||
-0.2000f, -8.6691f, -0.5593f, -0.5952f, -0.4203f, -0.4857f, -1.1239f,
|
||||
3.1404f, -13.1098f, -5.9165f, 22.2060f, -0.0312f, -3.9642f, -0.0344f,
|
||||
-0.0656f, -0.0273f, -0.0465f, 0.1412f, -6.1974f, 9.3661f,
|
||||
-0.1758f, -0.0499f, -10.0069f, -2.2838f, -0.3359f, 0.3459f, -0.3285f,
|
||||
-0.0515f, -0.5417f, 0.2357f, -0.0575f, -69.0782f, 0.5348f, 1.4068f,
|
||||
0.2213f, -1.0490f, -0.0636f, 0.1654f, 1.1002f, 33.4924f, 0.4358f,
|
||||
1.2499f, 0.1143f, 0.0592f, -1.6335f, -0.0092f, 1.2207f, -28.4543f,
|
||||
-0.4973f, 0.4368f, 0.2341f, -0.1623f, -3.8986f, 0.1311f, -1.8789f,
|
||||
-3.9079f, -0.8158f, -0.8420f, 1.4295f, -2.3629f, -1.4825f, 0.6498f,
|
||||
-5.3669f, 6.4434f, 1.8393f, -35.0678f, 3.7459f, -2.8504f, 2.0502f,
|
||||
-0.1812f, -3.9011f, -1.0155f, 1.8375f, -1.4517f, 1.3917f, 3.8664f,
|
||||
0.8345f, -0.3472f, 5.7740f, -1.1196f, -0.3264f, -1.2481f, -0.9284f,
|
||||
-4.9657f, 2.2831f, 0.7337f, 2.3176f, 0.6416f, 0.8804f, 1.9988f,
|
||||
-1.3426f, 1.2728f, 1.2249f, -0.1551f, 5.6045f, 0.2046f, -2.1464f,
|
||||
-2.4922f, -0.5334f, 12.1055f, 7.2467f, -0.0070f, 0.0234f, 0.0021f,
|
||||
0.0215f, -0.0098f, -0.0682f, -6.1494f, -0.3176f, -1.6069f, -0.2119f,
|
||||
-1.0533f, -0.3566f, 0.5294f, -0.4335f, 0.1626f,
|
||||
};
|
||||
|
||||
static const float av1_pustats_rate_hiddenlayer_0_bias[HIDDEN_LAYERS_0_NODES] =
|
||||
{
|
||||
-14.3065f, 2.059f, -62.9916f, -50.1209f, 57.643f, -59.3737f,
|
||||
-30.4737f, -0.1112f, 72.5427f, 55.402f, 24.9523f, 18.5834f,
|
||||
10.5266f, 5.3268f, -1.0678f, 7.7411f, 8.7164f, -0.3235f,
|
||||
7.3028f, 9.0874f, -6.4594f, -1.0102f, -1.1146f, 10.8419f,
|
||||
};
|
||||
|
||||
static const float
|
||||
av1_pustats_rate_hiddenlayer_1_kernel[HIDDEN_LAYERS_0_NODES *
|
||||
HIDDEN_LAYERS_1_NODES] = {
|
||||
0.3883f, -0.2784f, -0.2850f, 0.4894f, -2.2450f, 0.4511f, -0.1969f,
|
||||
-0.0077f, -1.4924f, 0.1138f, -2.9848f, 1.0211f, -0.1712f, -0.1952f,
|
||||
-0.4774f, 0.0761f, -0.3186f, -0.1002f, 0.8663f, 0.5026f, 1.1920f,
|
||||
0.9337f, 0.3911f, -0.3841f, -0.0037f, 0.7295f, -0.3183f, 0.1829f,
|
||||
-1.3670f, -0.1046f, 0.6629f, 0.0619f, -0.1551f, 0.8174f, 2.1521f,
|
||||
-1.3323f, -0.0527f, -0.5772f, 0.2001f, -0.6270f, -1.0625f, 0.3342f,
|
||||
0.6676f, 0.4605f, -2.0049f, 0.7781f, 0.0713f, -0.0824f, -0.4529f,
|
||||
0.1757f, -0.1338f, -0.2319f, -0.2864f, 0.1248f, 0.3887f, -0.1676f,
|
||||
1.8422f, 0.6435f, 1.2123f, -0.5667f, -0.2423f, -0.0314f, 0.2411f,
|
||||
-0.5013f, 0.0422f, 0.2559f, 0.4435f, -0.1223f, 1.5167f, 0.3939f,
|
||||
1.0898f, 0.0795f, -0.9251f, -0.0813f, -0.5929f, -0.0741f, 4.0687f,
|
||||
-0.4368f, -0.0984f, 0.0837f, 3.6169f, 0.0662f, -0.1679f, -0.8090f,
|
||||
-0.2610f, -0.5791f, 0.0642f, -0.2979f, -0.9036f, 0.2898f, 0.3265f,
|
||||
0.4660f, -1.6358f, -0.0347f, 0.1087f, 0.0353f, 0.5687f, -0.5242f,
|
||||
-0.4895f, 0.7693f, -1.3829f, -0.2244f, -0.2880f, 0.0575f, 2.0563f,
|
||||
-0.2322f, -1.1597f, 1.6125f, -0.0925f, 1.3540f, 0.1432f, 0.3993f,
|
||||
-0.0303f, -1.1438f, -1.7323f, -0.4329f, 2.9443f, -0.5724f, 0.0122f,
|
||||
-1.0829f,
|
||||
10.5932f, 2.5192f, -0.0015f, 5.9479f, 5.2426f, -0.4091f, 5.3220f,
|
||||
6.0469f, 0.7200f, 3.3241f, 5.5006f, 12.8290f, -1.6396f, 0.5743f,
|
||||
-0.8370f, 1.9956f, -4.9270f, -1.5295f, 2.1350f, -9.4415f, -0.7094f,
|
||||
5.1822f, 19.7287f, -3.0444f, -0.3320f, 0.0031f, -0.2709f, -0.5249f,
|
||||
0.3281f, -0.2240f, 0.2225f, -0.2386f, -0.4370f, -0.2438f, -0.4928f,
|
||||
-0.2842f, -2.1772f, 9.2570f, -17.6655f, 3.5448f, -2.8394f, -1.0167f,
|
||||
-0.5115f, -1.9260f, -0.2111f, -0.7528f, -1.2387f, -0.0401f, 5.0716f,
|
||||
-3.3763f, -0.2898f, -0.4956f, -7.9993f, 0.1526f, -0.0242f, 0.7354f,
|
||||
6.0432f, 4.8043f, 7.4790f, -0.6295f, 1.7565f, 3.7197f, -2.3963f,
|
||||
6.8945f, 2.9717f, -3.1623f, 3.4241f, 4.4676f, -1.8154f, -2.9401f,
|
||||
-8.5657f, -3.0240f, -1.4661f, 8.1145f, -12.7858f, 3.3624f, -1.0819f,
|
||||
-4.2856f, 1.1801f, -0.5587f, -1.6062f, -1.1813f, -3.5882f, -0.2490f,
|
||||
-24.9566f, -0.4140f, -0.1113f, 3.5537f, 4.4112f, 0.1367f, -1.5876f,
|
||||
1.6605f, 1.3903f, -0.0253f, -2.1419f, -2.2197f, -0.7659f, -0.4249f,
|
||||
-0.0424f, 0.1486f, 0.4643f, -0.9068f, -0.3619f, -0.7624f, -0.9132f,
|
||||
-0.4947f, -0.3527f, -0.5445f, -0.4768f, -1.7761f, -1.0686f, 0.5462f,
|
||||
1.3371f, 4.3116f, 0.0777f, -2.7216f, -1.8908f, 3.4989f, 7.7269f,
|
||||
-2.7566f,
|
||||
};
|
||||
|
||||
static const float av1_pustats_rate_hiddenlayer_1_bias[HIDDEN_LAYERS_1_NODES] =
|
||||
{
|
||||
-10.3717f, 37.304f, -36.7221f, -52.7572f, 44.0877f,
|
||||
41.1631f, 36.3299f, -48.6087f, -4.5189f, 13.0611f,
|
||||
13.2435f, -8.5477f, -0.0998f, -1.5131f, -12.0187f,
|
||||
6.1715f, 0.5094f, 7.6433f, -0.3992f, -1.3555f,
|
||||
};
|
||||
|
||||
static const float
|
||||
av1_pustats_rate_logits_kernel[HIDDEN_LAYERS_1_NODES * LOGITS_NODES] = {
|
||||
0.8362f, 1.0615f, -1.5178f, -1.2959f, 1.3233f,
|
||||
1.4909f, 1.3554f, -0.8626f, -0.618f, -0.9458f,
|
||||
4.3078f, -17.3497f, 0.0195f, 34.6032f, -5.0127f,
|
||||
5.3079f, 10.0077f, -13.129f, 0.0087f, -8.4009f,
|
||||
};
|
||||
|
||||
static const float av1_pustats_rate_logits_bias[LOGITS_NODES] = {
|
||||
30.6878f,
|
||||
4.5103f,
|
||||
};
|
||||
|
||||
static const NN_CONFIG av1_pustats_rate_nnconfig = {
|
||||
NUM_FEATURES, // num_inputs
|
||||
NUM_FEATURES_PUSTATS, // num_inputs
|
||||
LOGITS_NODES, // num_outputs
|
||||
NUM_HIDDEN_LAYERS, // num_hidden_layers
|
||||
{ HIDDEN_LAYERS_0_NODES, HIDDEN_LAYERS_1_NODES }, // num_hidden_nodes
|
||||
|
|
@ -111,76 +106,71 @@ static const NN_CONFIG av1_pustats_rate_nnconfig = {
|
|||
};
|
||||
|
||||
static const float
|
||||
av1_pustats_dist_hiddenlayer_0_kernel[NUM_FEATURES *
|
||||
av1_pustats_dist_hiddenlayer_0_kernel[NUM_FEATURES_PUSTATS *
|
||||
HIDDEN_LAYERS_0_NODES] = {
|
||||
0.7770f, 1.0881f, 0.0177f, 0.4939f, -0.2541f, -0.2672f, -0.1705f,
|
||||
-0.1940f, -0.6395f, 1.2928f, 3.6240f, 2.4445f, 1.6790f, 0.0265f,
|
||||
0.1897f, 0.1776f, 0.0422f, 0.0197f, -0.0466f, 0.0462f, -1.0827f,
|
||||
2.0231f, 1.8044f, 2.7022f, 0.0064f, 0.2255f, -0.0552f, -0.1010f,
|
||||
-0.0581f, -0.0781f, 0.2614f, -3.4085f, 1.7478f, 0.1155f, -0.1458f,
|
||||
-0.0031f, -0.1797f, -0.4378f, -0.0539f, 0.0607f, -0.1347f, -0.3142f,
|
||||
-0.2014f, -0.4484f, -0.2808f, 1.5913f, 0.0046f, -0.0610f, -0.6479f,
|
||||
-0.7278f, -0.5592f, -0.6695f, -0.8120f, 2.9056f, -1.1501f, 9.3618f,
|
||||
4.2486f, 0.0011f, -0.1499f, -0.0834f, 0.1282f, 0.0409f, 0.1670f,
|
||||
-0.1398f, -0.4661f, 13.7700f, 8.2061f, -0.0685f, 0.0061f, -0.2951f,
|
||||
0.0169f, 0.0520f, 0.0040f, 0.0374f, 0.0467f, -0.0107f, 14.2664f,
|
||||
-2.2489f, -0.2516f, -0.0061f, -0.9921f, 0.1223f, 0.1212f, 0.1199f,
|
||||
0.1185f, -0.4867f, 0.0325f, -5.0757f, -8.7853f, 1.0450f, 0.0169f,
|
||||
0.5462f, 0.0051f, 0.1330f, 0.0143f, 0.1429f, -0.0258f, 0.2769f,
|
||||
-12.8839f, 22.3093f, 1.2761f, 0.0037f, -1.2459f, -0.0466f, 0.0003f,
|
||||
-0.0464f, -0.0067f, 0.2361f, 0.0355f, 23.3833f, 10.9218f, 2.6811f,
|
||||
0.0222f, -1.1055f, 0.1825f, 0.0575f, 0.0114f, -0.1259f, 0.3148f,
|
||||
-2.0047f, 11.9559f, 5.7375f, 0.8802f, 0.0042f, -0.2469f, -0.1040f,
|
||||
-1.5679f, 0.1969f, -0.0184f, 0.0157f, 0.6688f, 3.4492f,
|
||||
-0.2560f, 0.1105f, -0.8434f, -0.0132f, -8.9371f, -1.1176f, -0.3655f,
|
||||
0.4885f, 1.7518f, 0.4985f, 0.5582f, -0.3739f, 0.9403f, 0.3874f,
|
||||
0.3265f, 1.7383f, 3.1747f, 0.0285f, 3.3942f, -0.0123f, 0.5057f,
|
||||
0.1584f, 0.2697f, 4.6151f, 3.6251f, -0.0121f, -1.0047f, -0.0037f,
|
||||
0.0127f, 0.1935f, -0.5277f, -2.7144f, 0.0729f, -0.1457f, -0.0816f,
|
||||
-0.5462f, 0.4738f, 0.3599f, -0.0564f, 0.0910f, 0.0126f, -0.0310f,
|
||||
-2.1311f, -0.4666f, -0.0074f, -0.0765f, 0.0287f, -0.2662f, -0.0999f,
|
||||
-0.2983f, -0.4899f, -0.2314f, 0.2873f, -0.3614f, 0.1783f, -0.1210f,
|
||||
0.3569f, 0.5436f, -8.0536f, -0.0044f, -1.5255f, -0.8247f, -0.4556f,
|
||||
1.9045f, 0.5463f, 0.1102f, -0.9293f, -0.0185f, -0.8302f, -0.4378f,
|
||||
-0.3531f, -1.3095f, 0.6099f, 0.7977f, 4.1950f, -0.0067f, -0.2762f,
|
||||
-0.1574f, -0.2149f, 0.6104f, -1.7053f, 0.1904f, 4.2402f, -0.2671f,
|
||||
0.8940f, 0.6820f, 0.2241f, -0.9459f, 1.4571f, 0.5255f, 2.3352f,
|
||||
-0.0806f, 0.5231f, 0.3928f, 0.4146f, 2.0956f,
|
||||
};
|
||||
|
||||
static const float av1_pustats_dist_hiddenlayer_0_bias[HIDDEN_LAYERS_0_NODES] =
|
||||
{
|
||||
4.5051f, -4.5858f, 1.4693f, 0.f, 3.7968f, -3.6292f,
|
||||
-7.3112f, 10.9743f, 8.027f, -2.2692f, -8.748f, -1.3689f,
|
||||
1.1597f, 0.0836f, -0.7471f, -0.2439f, -0.0438f, 2.4626f,
|
||||
0.f, 1.1485f, 2.7085f, -4.7897f, 1.4093f, -1.657f,
|
||||
};
|
||||
|
||||
static const float
|
||||
av1_pustats_dist_hiddenlayer_1_kernel[HIDDEN_LAYERS_0_NODES *
|
||||
HIDDEN_LAYERS_1_NODES] = {
|
||||
-0.0182f, -0.0925f, -0.0311f, -0.2962f, 0.1177f, -0.0027f, -0.2136f,
|
||||
-1.2094f, 0.0935f, -0.1403f, -0.1477f, -0.0752f, 0.1519f, -0.4726f,
|
||||
-0.3521f, 0.4199f, -0.0168f, -0.2927f, -0.2510f, 0.0706f, -0.2920f,
|
||||
0.2046f, -0.0400f, -0.2114f, 0.4240f, -0.7070f, 0.4964f, 0.4471f,
|
||||
0.3841f, -0.0918f, -0.6140f, 0.6056f, -0.1123f, 0.3944f, -0.0178f,
|
||||
-1.7702f, -0.4434f, 0.0560f, 0.1565f, -0.0793f, -0.0041f, 0.0052f,
|
||||
-0.1843f, 0.2400f, -0.0605f, 0.3196f, -0.0286f, -0.0002f, -0.0595f,
|
||||
-0.0493f, -0.2636f, -0.3994f, -0.1871f, -0.3298f, -0.0788f, -1.0685f,
|
||||
0.1900f, -0.5549f, -0.1350f, -0.0153f, -0.1195f, -0.5874f, 1.0468f,
|
||||
0.0212f, -0.2306f, -0.2677f, -0.3000f, -1.0702f, -0.1725f, -0.0656f,
|
||||
-0.0226f, 0.0616f, -0.3453f, 0.0810f, 0.4838f, -0.3780f, -1.4486f,
|
||||
0.7777f, -0.0459f, -0.6568f, 0.0589f, -1.0286f, -0.6001f, 0.0826f,
|
||||
0.4794f, -0.0586f, -0.1759f, 0.3811f, -0.1313f, 0.3829f, -0.0968f,
|
||||
-2.0445f, -0.3566f, -0.1491f, -0.0745f, -0.0202f, 0.0839f, 0.0470f,
|
||||
-0.2432f, 0.3013f, -0.0743f, -0.3479f, 0.0749f, -5.2490f, 0.0209f,
|
||||
-0.1653f, -0.0826f, -0.0535f, 0.3225f, -0.3786f, -0.0104f, 0.3091f,
|
||||
0.3652f, 0.1757f, -0.3252f, -1.1022f, -0.0574f, -0.4473f, 0.3469f,
|
||||
-0.5539f,
|
||||
-0.5203f, -1.3468f, 0.3865f, -0.6859f, 0.0058f, 4.0682f, 0.4807f,
|
||||
-0.1380f, 0.6050f, 0.8958f, 0.7748f, -0.1311f, 1.7317f, 1.1265f,
|
||||
0.0827f, 0.1407f, -0.3605f, 0.5429f, 0.1880f, -0.1439f, 0.2837f,
|
||||
1.6477f, 0.0832f, 0.0593f, -1.8464f, -0.7241f, -1.0672f, -0.3546f,
|
||||
-0.3842f, -2.3637f, 0.2514f, 0.8263f, -0.1872f, 0.5774f, -0.3610f,
|
||||
-0.0205f, 1.3977f, -0.1083f, 0.6923f, 1.3039f, -0.2870f, 1.0622f,
|
||||
-0.0566f, 0.2697f, -0.5429f, -0.6193f, 1.7559f, 0.3246f, 1.9159f,
|
||||
0.3744f, 0.0686f, 1.0191f, -0.4212f, 1.9591f, -0.0691f, -0.1085f,
|
||||
-1.2034f, 0.0606f, 1.0116f, 0.5565f, -0.1874f, -0.7898f, 0.4796f,
|
||||
0.2290f, 0.4334f, -0.5817f, -0.2949f, 0.1367f, -0.2932f, -1.1265f,
|
||||
0.0133f, -0.5309f, -3.3191f, 0.0939f, 0.3895f, -2.5812f, -0.0066f,
|
||||
-3.0063f, -0.2982f, 0.7309f, -0.2422f, -0.2770f, -0.7152f, 0.1700f,
|
||||
1.9630f, 0.1988f, 0.4194f, 0.8762f, 0.3402f, 0.1051f, -0.1598f,
|
||||
0.2405f, 0.0392f, 1.1256f, 1.5245f, 0.0950f, 0.2160f, -0.5023f,
|
||||
0.2584f, 0.2074f, 0.2218f, 0.3966f, -0.0921f, -0.2435f, -0.4560f,
|
||||
-1.1923f, -0.3716f, -0.3286f, -1.3225f, 0.1896f, -0.3342f, -0.7888f,
|
||||
-0.4488f, -1.7168f, 0.3341f, 0.1146f, 0.5226f, 0.2610f, -0.4574f,
|
||||
-0.4164f,
|
||||
};
|
||||
|
||||
static const float av1_pustats_dist_hiddenlayer_1_bias[HIDDEN_LAYERS_1_NODES] =
|
||||
{
|
||||
11.9337f, -0.3681f, -6.1324f, 12.674f, 9.0956f,
|
||||
4.6069f, -4.4158f, -12.4848f, 10.8473f, 5.7633f,
|
||||
-2.3014f, -2.4292f, 1.3317f, -3.2361f, -1.918f,
|
||||
2.7149f, -2.5649f, 2.7765f, 2.9617f, 2.7684f,
|
||||
};
|
||||
|
||||
static const float
|
||||
av1_pustats_dist_logits_kernel[HIDDEN_LAYERS_1_NODES * LOGITS_NODES] = {
|
||||
0.3245f, 0.2979f, -0.157f, -0.1441f, 0.1413f,
|
||||
-0.7496f, -0.1737f, -0.5322f, 0.0748f, 0.2518f,
|
||||
-0.6868f, -0.6715f, 0.449f, -1.293f, 0.6214f,
|
||||
0.9894f, -0.4342f, 0.7002f, 1.4363f, 0.6951f,
|
||||
};
|
||||
|
||||
static const float av1_pustats_dist_logits_bias[LOGITS_NODES] = {
|
||||
4.6065f,
|
||||
2.3371f,
|
||||
};
|
||||
|
||||
static const NN_CONFIG av1_pustats_dist_nnconfig = {
|
||||
NUM_FEATURES, // num_inputs
|
||||
NUM_FEATURES_PUSTATS, // num_inputs
|
||||
LOGITS_NODES, // num_outputs
|
||||
NUM_HIDDEN_LAYERS, // num_hidden_layers
|
||||
{ HIDDEN_LAYERS_0_NODES, HIDDEN_LAYERS_1_NODES }, // num_hidden_nodes
|
||||
|
|
@ -196,7 +186,6 @@ static const NN_CONFIG av1_pustats_dist_nnconfig = {
|
|||
},
|
||||
};
|
||||
|
||||
#undef NUM_FEATURES
|
||||
#undef NUM_HIDDEN_LAYERS
|
||||
#undef HIDDEN_LAYERS_0_NODES
|
||||
#undef HIDDEN_LAYERS_1_NODES
|
||||
|
|
@ -206,4 +195,4 @@ static const NN_CONFIG av1_pustats_dist_nnconfig = {
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_PUSTATS_H_
|
||||
#endif // AOM_AV1_ENCODER_PUSTATS_H_
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/random.h
vendored
6
third_party/aom/av1/encoder/random.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_RANDOM_H_
|
||||
#define AV1_ENCODER_RANDOM_H_
|
||||
#ifndef AOM_AV1_ENCODER_RANDOM_H_
|
||||
#define AOM_AV1_ENCODER_RANDOM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -26,4 +26,4 @@ static INLINE unsigned int lcg_rand16(unsigned int *state) {
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_RANDOM_H_
|
||||
#endif // AOM_AV1_ENCODER_RANDOM_H_
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/ransac.h
vendored
6
third_party/aom/av1/encoder/ransac.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_RANSAC_H_
|
||||
#define AV1_ENCODER_RANSAC_H_
|
||||
#ifndef AOM_AV1_ENCODER_RANSAC_H_
|
||||
#define AOM_AV1_ENCODER_RANSAC_H_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -32,4 +32,4 @@ int ransac_rotzoom(int *matched_points, int npoints, int *num_inliers_by_motion,
|
|||
int ransac_translation(int *matched_points, int npoints,
|
||||
int *num_inliers_by_motion, double *params_by_motion,
|
||||
int num_motions);
|
||||
#endif // AV1_ENCODER_RANSAC_H_
|
||||
#endif // AOM_AV1_ENCODER_RANSAC_H_
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_RATE_DISTORTION_MODEL_PARAMS_H_
|
||||
#define AV1_ENCODER_RATE_DISTORTION_MODEL_PARAMS_H_
|
||||
#ifndef AOM_AV1_ENCODER_RATE_DISTORTION_MODEL_PARAMS_H_
|
||||
#define AOM_AV1_ENCODER_RATE_DISTORTION_MODEL_PARAMS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -588,4 +588,4 @@ static const NN_CONFIG av1_rdcost_model_nnconfig = {
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_RATE_DISTORTION_MODEL_PARAMS_H_
|
||||
#endif // AOM_AV1_ENCODER_RATE_DISTORTION_MODEL_PARAMS_H_
|
||||
|
|
|
|||
96
third_party/aom/av1/encoder/ratectrl.c
vendored
96
third_party/aom/av1/encoder/ratectrl.c
vendored
|
|
@ -117,7 +117,7 @@ static void init_minq_luts(int *kf_low_m, int *kf_high_m, int *arfgf_low,
|
|||
for (i = 0; i < QINDEX_RANGE; i++) {
|
||||
const double maxq = av1_convert_qindex_to_q(i, bit_depth);
|
||||
kf_low_m[i] = get_minq_index(maxq, 0.000001, -0.0004, 0.150, bit_depth);
|
||||
kf_high_m[i] = get_minq_index(maxq, 0.0000021, -0.00125, 0.55, bit_depth);
|
||||
kf_high_m[i] = get_minq_index(maxq, 0.0000021, -0.00125, 0.45, bit_depth);
|
||||
arfgf_low[i] = get_minq_index(maxq, 0.0000015, -0.0009, 0.30, bit_depth);
|
||||
arfgf_high[i] = get_minq_index(maxq, 0.0000021, -0.00125, 0.55, bit_depth);
|
||||
inter[i] = get_minq_index(maxq, 0.00000271, -0.00113, 0.90, bit_depth);
|
||||
|
|
@ -253,6 +253,9 @@ int av1_rc_get_default_min_gf_interval(int width, int height,
|
|||
int av1_rc_get_default_max_gf_interval(double framerate, int min_gf_interval) {
|
||||
int interval = AOMMIN(MAX_GF_INTERVAL, (int)(framerate * 0.75));
|
||||
interval += (interval & 0x01); // Round to even value
|
||||
#if CONFIG_FIX_GF_LENGTH
|
||||
interval = AOMMAX(FIXED_GF_LENGTH, interval);
|
||||
#endif
|
||||
return AOMMAX(interval, min_gf_interval);
|
||||
}
|
||||
|
||||
|
|
@ -299,9 +302,9 @@ void av1_rc_init(const AV1EncoderConfig *oxcf, int pass, RATE_CONTROL *rc) {
|
|||
rc->avg_q = av1_convert_qindex_to_q(oxcf->worst_allowed_q, oxcf->bit_depth);
|
||||
|
||||
for (i = 0; i < RATE_FACTOR_LEVELS; ++i) {
|
||||
rc->rate_correction_factors[i] = 1.0;
|
||||
rc->rate_correction_factors[i] = 0.7;
|
||||
}
|
||||
|
||||
rc->rate_correction_factors[KF_STD] = 1.0;
|
||||
rc->min_gf_interval = oxcf->min_gf_interval;
|
||||
rc->max_gf_interval = oxcf->max_gf_interval;
|
||||
if (rc->min_gf_interval == 0)
|
||||
|
|
@ -556,6 +559,14 @@ static int get_gf_active_quality(const RATE_CONTROL *const rc, int q,
|
|||
arfgf_low_motion_minq, arfgf_high_motion_minq);
|
||||
}
|
||||
|
||||
#if REDUCE_LAST_ALT_BOOST
|
||||
static int get_gf_high_motion_quality(int q, aom_bit_depth_t bit_depth) {
|
||||
int *arfgf_high_motion_minq;
|
||||
ASSIGN_MINQ_TABLE(bit_depth, arfgf_high_motion_minq);
|
||||
return arfgf_high_motion_minq[q];
|
||||
}
|
||||
#endif
|
||||
|
||||
static int calc_active_worst_quality_one_pass_vbr(const AV1_COMP *cpi) {
|
||||
const RATE_CONTROL *const rc = &cpi->rc;
|
||||
const unsigned int curr_frame = cpi->common.current_video_frame;
|
||||
|
|
@ -918,7 +929,7 @@ int av1_frame_type_qdelta(const AV1_COMP *cpi, int rf_level, int q) {
|
|||
#define STATIC_MOTION_THRESH 95
|
||||
static int rc_pick_q_and_bounds_two_pass(const AV1_COMP *cpi, int width,
|
||||
int height, int *bottom_index,
|
||||
int *top_index) {
|
||||
int *top_index, int *arf_q) {
|
||||
const AV1_COMMON *const cm = &cpi->common;
|
||||
const RATE_CONTROL *const rc = &cpi->rc;
|
||||
const AV1EncoderConfig *const oxcf = &cpi->oxcf;
|
||||
|
|
@ -959,7 +970,7 @@ static int rc_pick_q_and_bounds_two_pass(const AV1_COMP *cpi, int width,
|
|||
qindex = rc->last_boosted_qindex;
|
||||
last_boosted_q = av1_convert_qindex_to_q(qindex, bit_depth);
|
||||
delta_qindex = av1_compute_qdelta(rc, last_boosted_q,
|
||||
last_boosted_q * 0.75, bit_depth);
|
||||
last_boosted_q * 0.5, bit_depth);
|
||||
active_best_quality = AOMMAX(qindex + delta_qindex, rc->best_quality);
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1000,17 +1011,49 @@ static int rc_pick_q_and_bounds_two_pass(const AV1_COMP *cpi, int width,
|
|||
// For constrained quality dont allow Q less than the cq level
|
||||
if (oxcf->rc_mode == AOM_CQ) {
|
||||
if (q < cq_level) q = cq_level;
|
||||
#if USE_SYMM_MULTI_LAYER && MULTI_LVL_BOOST_VBR_CQ
|
||||
if (gf_group->update_type[gf_group->index] == ARF_UPDATE ||
|
||||
(is_intrl_arf_boost && !cpi->new_bwdref_update_rule)) {
|
||||
#endif // USE_SYMM_MULTI_LAYER && MULTI_LVL_BOOST_VBR_CQ
|
||||
active_best_quality = get_gf_active_quality(rc, q, bit_depth);
|
||||
|
||||
active_best_quality = get_gf_active_quality(rc, q, bit_depth);
|
||||
|
||||
// Constrained quality use slightly lower active best.
|
||||
active_best_quality = active_best_quality * 15 / 16;
|
||||
// Constrained quality use slightly lower active best.
|
||||
active_best_quality = active_best_quality * 15 / 16;
|
||||
#if REDUCE_LAST_ALT_BOOST
|
||||
if (gf_group->update_type[gf_group->index] == ARF_UPDATE) {
|
||||
const int min_boost = get_gf_high_motion_quality(q, bit_depth);
|
||||
const int boost = min_boost - active_best_quality;
|
||||
|
||||
active_best_quality = min_boost - (int)(boost * rc->arf_boost_factor);
|
||||
}
|
||||
#endif
|
||||
*arf_q = active_best_quality;
|
||||
#if USE_SYMM_MULTI_LAYER && MULTI_LVL_BOOST_VBR_CQ
|
||||
} else {
|
||||
active_best_quality = rc->arf_q;
|
||||
int this_height = gf_group->pyramid_level[gf_group->index];
|
||||
while (this_height < gf_group->pyramid_height) {
|
||||
active_best_quality = (active_best_quality + cq_level + 1) / 2;
|
||||
++this_height;
|
||||
}
|
||||
}
|
||||
#endif // USE_SYMM_MULTI_LAYER && MULTI_LVL_BOOST_VBR_CQ
|
||||
} else if (oxcf->rc_mode == AOM_Q) {
|
||||
if (!cpi->refresh_alt_ref_frame && !is_intrl_arf_boost) {
|
||||
active_best_quality = cq_level;
|
||||
} else {
|
||||
active_best_quality = get_gf_active_quality(rc, q, bit_depth);
|
||||
if (gf_group->update_type[gf_group->index] == ARF_UPDATE) {
|
||||
active_best_quality = get_gf_active_quality(rc, q, bit_depth);
|
||||
*arf_q = active_best_quality;
|
||||
#if REDUCE_LAST_ALT_BOOST
|
||||
const int min_boost = get_gf_high_motion_quality(q, bit_depth);
|
||||
const int boost = min_boost - active_best_quality;
|
||||
|
||||
active_best_quality = min_boost - (int)(boost * rc->arf_boost_factor);
|
||||
#endif
|
||||
} else {
|
||||
active_best_quality = rc->arf_q;
|
||||
}
|
||||
#if USE_SYMM_MULTI_LAYER
|
||||
if (cpi->new_bwdref_update_rule && is_intrl_arf_boost) {
|
||||
int this_height = gf_group->pyramid_level[gf_group->index];
|
||||
|
|
@ -1030,6 +1073,12 @@ static int rc_pick_q_and_bounds_two_pass(const AV1_COMP *cpi, int width,
|
|||
}
|
||||
} else {
|
||||
active_best_quality = get_gf_active_quality(rc, q, bit_depth);
|
||||
#if REDUCE_LAST_ALT_BOOST
|
||||
const int min_boost = get_gf_high_motion_quality(q, bit_depth);
|
||||
const int boost = min_boost - active_best_quality;
|
||||
|
||||
active_best_quality = min_boost - (int)(boost * rc->arf_boost_factor);
|
||||
#endif
|
||||
#if USE_SYMM_MULTI_LAYER
|
||||
if (cpi->new_bwdref_update_rule && is_intrl_arf_boost) {
|
||||
int this_height = gf_group->pyramid_level[gf_group->index];
|
||||
|
|
@ -1104,7 +1153,8 @@ static int rc_pick_q_and_bounds_two_pass(const AV1_COMP *cpi, int width,
|
|||
if (cpi->twopass.last_kfgroup_zeromotion_pct >= STATIC_MOTION_THRESH) {
|
||||
q = AOMMIN(rc->last_kf_qindex, rc->last_boosted_qindex);
|
||||
} else {
|
||||
q = rc->last_boosted_qindex;
|
||||
q = AOMMIN(rc->last_boosted_qindex,
|
||||
(active_best_quality + active_worst_quality) / 2);
|
||||
}
|
||||
} else {
|
||||
q = av1_rc_regulate_q(cpi, rc->this_frame_target, active_best_quality,
|
||||
|
|
@ -1129,7 +1179,7 @@ static int rc_pick_q_and_bounds_two_pass(const AV1_COMP *cpi, int width,
|
|||
return q;
|
||||
}
|
||||
|
||||
int av1_rc_pick_q_and_bounds(const AV1_COMP *cpi, int width, int height,
|
||||
int av1_rc_pick_q_and_bounds(AV1_COMP *cpi, int width, int height,
|
||||
int *bottom_index, int *top_index) {
|
||||
int q;
|
||||
if (cpi->oxcf.pass == 0) {
|
||||
|
|
@ -1140,8 +1190,17 @@ int av1_rc_pick_q_and_bounds(const AV1_COMP *cpi, int width, int height,
|
|||
q = rc_pick_q_and_bounds_one_pass_vbr(cpi, width, height, bottom_index,
|
||||
top_index);
|
||||
} else {
|
||||
assert(cpi->oxcf.pass == 2 && "invalid encode pass");
|
||||
|
||||
GF_GROUP *gf_group = &cpi->twopass.gf_group;
|
||||
int arf_q = 0;
|
||||
|
||||
q = rc_pick_q_and_bounds_two_pass(cpi, width, height, bottom_index,
|
||||
top_index);
|
||||
top_index, &arf_q);
|
||||
|
||||
if (gf_group->update_type[gf_group->index] == ARF_UPDATE) {
|
||||
cpi->rc.arf_q = arf_q;
|
||||
}
|
||||
}
|
||||
|
||||
return q;
|
||||
|
|
@ -1327,13 +1386,6 @@ void av1_rc_postencode_update(AV1_COMP *cpi, uint64_t bytes_used) {
|
|||
update_golden_frame_stats(cpi);
|
||||
|
||||
if (cm->frame_type == KEY_FRAME) rc->frames_since_key = 0;
|
||||
|
||||
// TODO(zoeliu): To investigate whether we should treat BWDREF_FRAME
|
||||
// differently here for rc->avg_frame_bandwidth.
|
||||
if (cm->show_frame || rc->is_bwd_ref_frame) {
|
||||
rc->frames_since_key++;
|
||||
rc->frames_to_key--;
|
||||
}
|
||||
// if (cm->current_video_frame == 1 && cm->show_frame)
|
||||
/*
|
||||
rc->this_frame_target =
|
||||
|
|
@ -1635,10 +1687,6 @@ void av1_rc_set_gf_interval_range(const AV1_COMP *const cpi,
|
|||
if (rc->max_gf_interval > rc->static_scene_max_gf_interval)
|
||||
rc->max_gf_interval = rc->static_scene_max_gf_interval;
|
||||
|
||||
#if FIX_GF_INTERVAL_LENGTH
|
||||
rc->max_gf_interval = FIXED_GF_LENGTH + 1;
|
||||
#endif
|
||||
|
||||
// Clamp min to max
|
||||
rc->min_gf_interval = AOMMIN(rc->min_gf_interval, rc->max_gf_interval);
|
||||
}
|
||||
|
|
|
|||
29
third_party/aom/av1/encoder/ratectrl.h
vendored
29
third_party/aom/av1/encoder/ratectrl.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_RATECTRL_H_
|
||||
#define AV1_ENCODER_RATECTRL_H_
|
||||
#ifndef AOM_AV1_ENCODER_RATECTRL_H_
|
||||
#define AOM_AV1_ENCODER_RATECTRL_H_
|
||||
|
||||
#include "aom/aom_codec.h"
|
||||
#include "aom/aom_integer.h"
|
||||
|
|
@ -25,13 +25,27 @@ extern "C" {
|
|||
#define BPER_MB_NORMBITS 9
|
||||
|
||||
#define CUSTOMIZED_GF 1
|
||||
#define FIX_GF_INTERVAL_LENGTH 0
|
||||
|
||||
#if FIX_GF_INTERVAL_LENGTH
|
||||
#if CONFIG_FIX_GF_LENGTH
|
||||
#define FIXED_GF_LENGTH 16
|
||||
#define MAX_PYRAMID_LVL 4
|
||||
// We allow a frame to have at most two left/right descendants before changing
|
||||
// them into to a subtree, i.e., we allow the following structure:
|
||||
/* OUT_OF_ORDER_FRAME
|
||||
/ / \ \
|
||||
(two left children) F F F F (two right children) */
|
||||
// Therefore the max gf size supported by 4 layer structure is
|
||||
// 1 (KEY/OVERLAY) + 1 + 2 + 4 + 16 (two children on both side of their parent)
|
||||
#define MAX_PYRAMID_SIZE 24
|
||||
#define USE_SYMM_MULTI_LAYER 1
|
||||
#define REDUCE_LAST_ALT_BOOST 1
|
||||
#define REDUCE_LAST_GF_LENGTH 1
|
||||
#define MULTI_LVL_BOOST_VBR_CQ 1
|
||||
#else
|
||||
#define USE_SYMM_MULTI_LAYER 0
|
||||
#define REDUCE_LAST_ALT_BOOST 0
|
||||
#define REDUCE_LAST_GF_LENGTH 0
|
||||
#define MULTI_LVL_BOOST_VBR_CQ 0
|
||||
#endif
|
||||
|
||||
#if USE_SYMM_MULTI_LAYER
|
||||
|
|
@ -159,6 +173,9 @@ typedef struct {
|
|||
|
||||
// Auto frame-scaling variables.
|
||||
int rf_level_maxq[RATE_FACTOR_LEVELS];
|
||||
float_t arf_boost_factor;
|
||||
// Q index used for ALT frame
|
||||
int arf_q;
|
||||
} RATE_CONTROL;
|
||||
|
||||
struct AV1_COMP;
|
||||
|
|
@ -228,7 +245,7 @@ void av1_rc_compute_frame_size_bounds(const struct AV1_COMP *cpi,
|
|||
int *frame_over_shoot_limit);
|
||||
|
||||
// Picks q and q bounds given the target for bits
|
||||
int av1_rc_pick_q_and_bounds(const struct AV1_COMP *cpi, int width, int height,
|
||||
int av1_rc_pick_q_and_bounds(struct AV1_COMP *cpi, int width, int height,
|
||||
int *bottom_index, int *top_index);
|
||||
|
||||
// Estimates q to achieve a target bits per frame
|
||||
|
|
@ -275,4 +292,4 @@ int av1_resize_one_pass_cbr(struct AV1_COMP *cpi);
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_RATECTRL_H_
|
||||
#endif // AOM_AV1_ENCODER_RATECTRL_H_
|
||||
|
|
|
|||
0
third_party/aom/av1/encoder/ratectrl_xiph.c
vendored
0
third_party/aom/av1/encoder/ratectrl_xiph.c
vendored
0
third_party/aom/av1/encoder/ratectrl_xiph.h
vendored
0
third_party/aom/av1/encoder/ratectrl_xiph.h
vendored
494
third_party/aom/av1/encoder/rd.c
vendored
494
third_party/aom/av1/encoder/rd.c
vendored
|
|
@ -648,6 +648,473 @@ void av1_model_rd_from_var_lapndz(int64_t var, unsigned int n_log2,
|
|||
}
|
||||
}
|
||||
|
||||
static double interp_cubic(const double *p, double x) {
|
||||
return p[1] + 0.5 * x *
|
||||
(p[2] - p[0] +
|
||||
x * (2.0 * p[0] - 5.0 * p[1] + 4.0 * p[2] - p[3] +
|
||||
x * (3.0 * (p[1] - p[2]) + p[3] - p[0])));
|
||||
}
|
||||
|
||||
static double interp_bicubic(const double *p, int p_stride, double x,
|
||||
double y) {
|
||||
double q[4];
|
||||
q[0] = interp_cubic(p, x);
|
||||
q[1] = interp_cubic(p + p_stride, x);
|
||||
q[2] = interp_cubic(p + 2 * p_stride, x);
|
||||
q[3] = interp_cubic(p + 3 * p_stride, x);
|
||||
return interp_cubic(q, y);
|
||||
}
|
||||
|
||||
static const double interp_rgrid_surf[65 * 18] = {
|
||||
0.104019, 0.245714, 0.293686, 0.358635, 0.382167, 0.412446,
|
||||
0.419955, 0.421388, 0.426672, 0.427990, 0.428531, 0.456868,
|
||||
0.569880, 0.638822, 1.016319, 2.143453, 3.565229, 4.720880,
|
||||
0.124618, 0.294211, 0.352023, 0.429991, 0.458206, 0.494510,
|
||||
0.503513, 0.505232, 0.511566, 0.513234, 0.519365, 0.570225,
|
||||
0.697373, 0.840624, 1.462198, 3.289054, 6.256517, 6.852788,
|
||||
0.118630, 0.269669, 0.346620, 0.430999, 0.459385, 0.495783,
|
||||
0.504808, 0.506532, 0.512884, 0.514988, 0.543437, 0.662772,
|
||||
0.795876, 1.313596, 2.403841, 4.163098, 7.440589, 8.616275,
|
||||
0.093329, 0.168205, 0.321320, 0.430607, 0.459385, 0.495783,
|
||||
0.504813, 0.506548, 0.512975, 0.520662, 0.571659, 0.701841,
|
||||
1.010727, 2.138851, 3.460626, 6.317955, 10.098127, 14.418553,
|
||||
0.087021, 0.142905, 0.315011, 0.430509, 0.459385, 0.495787,
|
||||
0.505075, 0.507599, 0.513584, 0.543182, 0.669941, 0.825620,
|
||||
1.362800, 2.572187, 4.205047, 7.498399, 12.303118, 16.641735,
|
||||
0.086923, 0.142513, 0.314913, 0.430508, 0.459385, 0.495803,
|
||||
0.506126, 0.511816, 0.514810, 0.549705, 0.725350, 1.127334,
|
||||
2.168597, 3.463686, 6.318605, 10.162284, 18.556041, 19.847042,
|
||||
0.086923, 0.142513, 0.314913, 0.430506, 0.459376, 0.495805,
|
||||
0.506388, 0.512954, 0.520772, 0.580215, 0.810474, 1.391548,
|
||||
2.579442, 4.205160, 7.498399, 12.381597, 21.703618, 24.015457,
|
||||
0.086923, 0.142513, 0.314911, 0.430353, 0.458765, 0.495652,
|
||||
0.506391, 0.513406, 0.544098, 0.702950, 1.121860, 2.168961,
|
||||
3.463798, 6.318607, 10.162284, 18.685361, 28.188192, 37.638872,
|
||||
0.086923, 0.142513, 0.314901, 0.429742, 0.456313, 0.495045,
|
||||
0.506484, 0.519195, 0.580104, 0.810126, 1.391462, 2.579441,
|
||||
4.205160, 7.498399, 12.381597, 21.848607, 33.367199, 42.623190,
|
||||
0.086923, 0.142513, 0.314899, 0.429589, 0.455706, 0.495155,
|
||||
0.507882, 0.542426, 0.702360, 1.119921, 2.168478, 3.463791,
|
||||
6.318607, 10.162284, 18.685361, 28.345760, 47.802028, 49.163533,
|
||||
0.086924, 0.142548, 0.315086, 0.429842, 0.455870, 0.496336,
|
||||
0.512412, 0.556953, 0.773373, 1.266396, 2.548277, 4.204676,
|
||||
7.498399, 12.381597, 21.848607, 33.548250, 54.301011, 56.262859,
|
||||
0.087067, 0.144957, 0.327436, 0.446616, 0.466362, 0.505706,
|
||||
0.522077, 0.610747, 0.972543, 1.666916, 3.338812, 6.316669,
|
||||
10.162284, 18.685361, 28.345760, 48.065311, 66.145302, 78.396020,
|
||||
0.094295, 0.164235, 0.393722, 0.534219, 0.530922, 0.579308,
|
||||
0.603889, 0.760870, 1.229961, 2.423214, 4.173513, 7.497916,
|
||||
12.381597, 21.848607, 33.548250, 54.589585, 74.875848, 86.468182,
|
||||
0.124096, 0.213005, 0.497188, 0.665176, 0.685973, 0.800200,
|
||||
0.911394, 1.077971, 1.677290, 3.332129, 6.314960, 10.162257,
|
||||
18.685361, 28.345760, 48.065311, 66.453506, 98.275189, 96.862588,
|
||||
0.140999, 0.270140, 0.658212, 0.867661, 0.970183, 1.149516,
|
||||
1.480599, 1.664833, 2.421893, 3.857981, 7.418830, 12.380371,
|
||||
21.848607, 33.548250, 54.589585, 75.188867, 106.657971, 99.762997,
|
||||
0.178353, 0.398001, 0.988462, 1.241473, 1.340967, 1.713568,
|
||||
2.335030, 2.701432, 3.348532, 5.077158, 9.829903, 18.676528,
|
||||
28.345700, 48.065311, 66.453506, 98.588283, 117.057193, 101.130722,
|
||||
0.281079, 0.548300, 1.395825, 1.780770, 2.000508, 2.702964,
|
||||
3.638454, 4.573843, 5.051641, 7.079129, 11.293332, 21.594861,
|
||||
33.544335, 54.589585, 75.188867, 106.971065, 119.957601, 101.466632,
|
||||
0.476762, 0.842189, 2.019678, 2.723895, 3.188467, 4.011610,
|
||||
5.545111, 7.508984, 8.176339, 9.774504, 14.720782, 27.334416,
|
||||
48.049609, 66.453506, 98.588283, 117.370357, 121.329855, 101.509242,
|
||||
0.993999, 1.520111, 3.013605, 4.203530, 4.982992, 6.074944,
|
||||
8.583581, 11.818375, 14.192544, 14.937517, 21.258160, 33.305953,
|
||||
54.585735, 75.188867, 106.971135, 120.279824, 121.976055, 102.690130,
|
||||
1.776487, 2.613655, 4.356487, 6.161726, 7.622196, 9.464193,
|
||||
13.077233, 18.051656, 23.221051, 24.080068, 30.085038, 48.345269,
|
||||
66.457698, 98.588353, 117.379415, 121.976128, 124.356210, 107.713202,
|
||||
3.191085, 4.495201, 5.686033, 8.365566, 11.275339, 14.706437,
|
||||
20.300969, 28.152237, 35.688355, 39.341382, 41.030743, 55.752262,
|
||||
75.211764, 106.980285, 120.608403, 124.680746, 130.222528, 112.260098,
|
||||
6.136611, 7.305215, 7.272532, 10.646713, 15.630815, 22.383168,
|
||||
31.349131, 42.419822, 52.301680, 58.983454, 58.915405, 69.161305,
|
||||
98.992460, 117.713855, 124.344836, 130.623638, 138.442401, 127.846670,
|
||||
11.707980, 13.490761, 11.640845, 14.176132, 22.131124, 33.776462,
|
||||
47.365711, 61.603834, 75.281056, 83.463985, 85.510533, 86.026513,
|
||||
108.787480, 123.031136, 130.607284, 138.954406, 160.867784, 158.958882,
|
||||
27.062874, 32.195139, 24.147297, 22.114632, 35.580506, 52.551674,
|
||||
71.652956, 88.606776, 102.107193, 110.703186, 114.398733, 111.118539,
|
||||
121.503578, 132.455924, 139.490806, 161.412674, 193.563210, 172.203945,
|
||||
35.625692, 47.953028, 42.639820, 42.276254, 58.815664, 84.977282,
|
||||
110.656412, 126.168446, 134.658126, 140.604482, 144.006012, 141.702382,
|
||||
140.125323, 153.122630, 164.748041, 194.156197, 206.854650, 174.013079,
|
||||
49.516447, 65.335381, 71.738306, 81.872819, 98.400740, 136.840488,
|
||||
163.775802, 169.440078, 172.747876, 171.222919, 171.679604, 172.173550,
|
||||
168.200129, 187.617133, 199.683394, 207.768200, 210.062520, 175.478356,
|
||||
60.341673, 92.487135, 119.907299, 136.068010, 144.778950, 189.443534,
|
||||
220.120077, 219.641635, 214.616503, 205.894657, 198.453924, 200.013069,
|
||||
195.938103, 206.118661, 210.447375, 212.061379, 216.078218, 181.162805,
|
||||
78.422159, 112.242899, 158.416312, 181.404320, 193.188690, 229.296967,
|
||||
270.461799, 275.168977, 256.511701, 244.706786, 231.344608, 226.065087,
|
||||
222.248618, 218.662324, 217.966722, 218.248574, 218.818588, 182.740573,
|
||||
88.713664, 123.594164, 172.928179, 213.781414, 245.800351, 252.063414,
|
||||
313.283141, 331.703831, 305.866639, 285.177142, 269.759635, 251.988739,
|
||||
245.998388, 232.688076, 230.588702, 230.882657, 230.319053, 192.120741,
|
||||
102.540561, 152.905927, 189.137131, 241.806756, 273.868497, 284.258017,
|
||||
339.689853, 373.561104, 362.657463, 326.291984, 311.922687, 290.460189,
|
||||
276.774381, 273.012072, 277.751792, 279.123748, 278.820447, 233.813798,
|
||||
132.983118, 176.307242, 197.415684, 243.307787, 280.893995, 332.922370,
|
||||
340.329043, 404.530166, 419.475405, 375.775209, 351.300889, 340.042759,
|
||||
315.683832, 306.123530, 306.359319, 306.733063, 307.609556, 261.647847,
|
||||
149.579109, 185.925581, 207.937033, 245.159084, 301.890957, 350.040480,
|
||||
352.250771, 418.742329, 458.112686, 430.125208, 386.460441, 380.346839,
|
||||
354.679150, 337.305620, 334.504124, 335.889932, 341.060725, 286.898578,
|
||||
153.576812, 202.105624, 219.366967, 248.524506, 314.255692, 350.607526,
|
||||
390.567688, 408.629209, 488.000213, 480.563823, 432.461799, 410.412624,
|
||||
398.607371, 400.188740, 402.780916, 408.853470, 430.449735, 363.777088,
|
||||
161.353129, 214.848904, 231.549852, 258.536466, 313.163177, 368.140577,
|
||||
412.136393, 413.409032, 499.838438, 519.571063, 485.833867, 444.562715,
|
||||
435.738129, 442.358549, 450.166531, 453.208524, 458.424358, 385.823139,
|
||||
175.109034, 227.608058, 250.069563, 286.101747, 312.256740, 378.421485,
|
||||
413.344147, 435.058646, 476.960941, 542.448886, 530.189154, 495.408402,
|
||||
475.326752, 465.017144, 464.694045, 465.144689, 466.905382, 398.669138,
|
||||
184.750180, 240.766694, 283.240772, 305.480150, 322.409001, 374.526162,
|
||||
427.141326, 452.840323, 472.604139, 545.366105, 567.676694, 541.666203,
|
||||
509.591873, 492.044219, 492.778569, 493.765684, 493.235693, 413.684325,
|
||||
194.728357, 254.928927, 289.991157, 300.193195, 324.194589, 371.563147,
|
||||
439.226438, 468.295088, 495.654854, 533.506353, 587.476353, 578.298989,
|
||||
548.041942, 527.393885, 538.965146, 545.070442, 544.295454, 454.012211,
|
||||
205.195287, 283.135677, 297.921431, 319.295927, 355.621830, 392.466463,
|
||||
446.696167, 485.053519, 516.426615, 532.264584, 588.481600, 615.906737,
|
||||
589.319634, 555.754316, 558.389367, 569.094521, 569.779764, 475.384946,
|
||||
218.552054, 298.511016, 319.188338, 351.781666, 372.789510, 412.827434,
|
||||
464.569387, 506.270203, 533.049810, 553.347364, 580.644599, 632.759854,
|
||||
622.235843, 569.960552, 580.799340, 586.553714, 579.488366, 491.826482,
|
||||
244.803348, 299.790203, 324.187975, 363.280782, 403.710443, 441.724083,
|
||||
492.732682, 534.722691, 552.193622, 575.112647, 586.097705, 635.224970,
|
||||
644.642944, 606.017786, 640.321218, 642.316989, 616.397020, 548.300111,
|
||||
256.957358, 318.638991, 355.063346, 389.889307, 433.607315, 468.209001,
|
||||
515.178157, 573.556591, 578.113115, 587.246475, 601.762801, 638.454644,
|
||||
656.574853, 641.184609, 676.908189, 684.198162, 678.387412, 574.805864,
|
||||
251.211502, 323.448532, 364.227424, 411.792704, 462.226488, 503.572288,
|
||||
549.299249, 599.124071, 601.227977, 597.118176, 613.247552, 633.278532,
|
||||
658.074755, 664.930719, 685.731531, 693.632845, 693.076350, 578.326477,
|
||||
267.695377, 354.273736, 389.976833, 438.518178, 493.332686, 544.343027,
|
||||
588.895829, 620.206193, 628.327410, 606.067827, 620.998532, 657.985256,
|
||||
683.936059, 691.345257, 693.894723, 695.175306, 693.618786, 578.517148,
|
||||
274.290725, 363.465288, 411.808596, 463.369805, 515.310226, 581.009306,
|
||||
613.070738, 636.638714, 647.333929, 629.867603, 644.646319, 687.796202,
|
||||
702.859596, 713.495479, 704.068069, 704.991807, 704.188594, 587.283658,
|
||||
302.538449, 389.174737, 438.518422, 493.398902, 547.662399, 601.981814,
|
||||
624.773046, 641.629484, 644.699451, 645.848784, 668.033340, 703.643523,
|
||||
707.422408, 717.329600, 726.298973, 744.127507, 745.365167, 617.954068,
|
||||
310.328188, 410.984766, 463.369805, 515.315010, 581.309832, 613.787792,
|
||||
634.988538, 654.145284, 662.632978, 668.413496, 706.494057, 750.545471,
|
||||
730.724808, 730.002100, 743.625262, 750.801609, 745.308457, 606.505800,
|
||||
329.948756, 437.600191, 493.398902, 547.661910, 601.917884, 622.557745,
|
||||
633.244395, 644.055898, 648.224221, 665.062911, 763.555733, 812.391078,
|
||||
769.063582, 744.865168, 727.579796, 724.950408, 722.179707, 598.564510,
|
||||
350.848328, 462.437458, 515.315010, 581.309823, 613.779123, 634.465309,
|
||||
652.056257, 662.179143, 671.466297, 726.881256, 819.824030, 880.232789,
|
||||
810.371672, 754.246481, 725.053473, 724.253390, 723.503395, 603.394909,
|
||||
373.704088, 492.408266, 547.661910, 601.917884, 622.557620, 633.236320,
|
||||
644.023513, 648.232514, 666.381639, 785.498283, 929.441612, 999.772800,
|
||||
890.339033, 775.852504, 731.840181, 726.905100, 725.251844, 604.899901,
|
||||
394.473422, 514.261306, 581.309823, 613.779123, 634.465309, 652.056257,
|
||||
662.179143, 671.466557, 727.134512, 835.764144, 981.747089, 1018.462934,
|
||||
939.686967, 811.276731, 739.398459, 727.365647, 725.285425, 604.923525,
|
||||
419.976505, 546.538939, 601.917884, 622.557620, 633.236320, 644.023513,
|
||||
648.232514, 666.381639, 785.545191, 932.841398, 1036.609617, 1026.945092,
|
||||
963.822765, 840.827315, 755.532423, 730.241865, 725.366847, 604.924155,
|
||||
437.281359, 580.116337, 613.779123, 634.465309, 652.056257, 662.179143,
|
||||
671.466557, 727.134512, 835.764859, 981.996194, 1031.896881, 1002.544732,
|
||||
881.157178, 828.151494, 799.340975, 751.314325, 728.316587, 605.005504,
|
||||
464.713920, 600.649281, 622.557620, 633.236320, 644.023513, 648.232514,
|
||||
666.381639, 785.545191, 932.841398, 1036.735329, 1035.037004, 995.478339,
|
||||
858.093733, 823.471976, 819.881754, 798.749289, 749.440463, 607.955244,
|
||||
495.880237, 612.473139, 634.465309, 652.056257, 662.179143, 671.466557,
|
||||
727.134512, 835.764859, 981.996194, 1032.339788, 1031.105117, 995.303259,
|
||||
857.733663, 823.435877, 822.822791, 819.873050, 796.882480, 629.038445,
|
||||
510.391280, 621.158273, 633.236320, 644.023513, 648.232514, 666.381639,
|
||||
785.545191, 932.841398, 1036.735329, 1035.566013, 1029.599350, 994.926093,
|
||||
857.645648, 823.435143, 822.904139, 822.822791, 817.965681, 673.856962,
|
||||
514.588176, 632.947715, 652.056257, 662.179143, 671.466557, 727.134512,
|
||||
835.764859, 981.996194, 1032.339788, 1031.547475, 1023.835377, 972.158629,
|
||||
851.968626, 823.347128, 822.904770, 822.904139, 820.752301, 684.418900,
|
||||
520.013294, 631.668183, 644.023513, 648.232514, 666.381639, 785.545191,
|
||||
932.841398, 1036.735329, 1035.567378, 1029.776746, 1001.044108, 880.853721,
|
||||
829.201546, 822.994150, 822.904770, 822.904770, 820.792975, 684.582020,
|
||||
531.253628, 650.479606, 662.179143, 671.466557, 727.134512, 835.764859,
|
||||
981.996194, 1032.339788, 1031.636855, 1029.601779, 995.366703, 858.086641,
|
||||
823.524524, 822.906135, 822.904770, 822.904770, 820.792975, 684.582020,
|
||||
528.531744, 642.424501, 648.232514, 666.381639, 785.545191, 932.841398,
|
||||
1036.735329, 1035.567378, 1030.219103, 1029.576226, 995.278687, 857.733663,
|
||||
823.436508, 822.904770, 822.904770, 822.904770, 820.792975, 684.582020,
|
||||
545.401164, 660.550678, 671.508859, 727.304161, 835.807162, 981.996850,
|
||||
1032.339788, 1031.636855, 1030.130788, 1029.487827, 994.925709, 857.645648,
|
||||
823.435143, 822.904770, 822.904770, 822.904770, 820.792975, 684.582020,
|
||||
537.684760, 646.650947, 669.110131, 796.487512, 935.569890, 1036.777631,
|
||||
1035.567378, 1030.219103, 1030.018584, 1023.810805, 972.158629, 851.968626,
|
||||
823.347128, 822.904770, 822.904770, 822.904770, 820.792975, 684.582020,
|
||||
552.408370, 670.001885, 738.246482, 879.690154, 992.939171, 1032.509436,
|
||||
1031.636855, 1030.132153, 1029.665223, 1001.043724, 880.853721, 829.201546,
|
||||
822.994150, 822.904770, 822.904770, 822.904770, 820.792975, 684.582020,
|
||||
539.835902, 667.496388, 799.216004, 946.512211, 1039.506123, 1035.609680,
|
||||
1030.219103, 1030.107964, 1029.577207, 995.366703, 858.086641, 823.524524,
|
||||
822.906135, 822.904770, 822.904770, 822.904770, 820.792975, 684.582020,
|
||||
558.362529, 734.277451, 877.197218, 990.478243, 1029.908393, 1028.993978,
|
||||
1027.488620, 1027.464048, 1026.933674, 992.724534, 855.532488, 821.323349,
|
||||
820.792975, 820.792975, 820.792975, 820.792975, 818.686600, 682.825198,
|
||||
453.127195, 649.075095, 780.278390, 867.165890, 862.469711, 857.067460,
|
||||
856.956321, 856.955937, 856.513579, 827.981461, 713.556496, 685.024378,
|
||||
684.582020, 684.582020, 684.582020, 684.582020, 682.825198, 569.510056,
|
||||
};
|
||||
|
||||
static const double interp_dgrid_surf[65 * 18] = {
|
||||
10.650434, 12.204694, 12.040917, 11.843008, 11.845578, 12.051535, 12.103583,
|
||||
12.136780, 12.266709, 12.299107, 12.299673, 12.303120, 12.316337, 12.293431,
|
||||
12.092165, 11.602421, 11.141559, 8.864495, 12.770003, 14.634889, 14.437149,
|
||||
14.199413, 14.202487, 14.449423, 14.511827, 14.551629, 14.707410, 14.746265,
|
||||
14.747610, 14.753705, 14.762194, 14.699395, 14.390525, 13.690970, 12.874168,
|
||||
10.367121, 12.832328, 14.790730, 14.503765, 14.236403, 14.239028, 14.486600,
|
||||
14.549164, 14.589069, 14.745250, 14.784258, 14.788320, 14.801930, 14.762798,
|
||||
14.499088, 14.021544, 13.469684, 12.661560, 10.108384, 12.950520, 15.264726,
|
||||
14.621957, 14.238236, 14.239028, 14.486601, 14.549264, 14.589469, 14.745361,
|
||||
14.784949, 14.791572, 14.798652, 14.660251, 14.119394, 13.651131, 12.935657,
|
||||
12.176082, 9.228999, 12.979992, 15.382918, 14.651428, 14.238693, 14.239028,
|
||||
14.486701, 14.555710, 14.615321, 14.751849, 14.787700, 14.797104, 14.743189,
|
||||
14.475057, 13.944406, 13.450468, 12.687876, 11.824993, 8.906683, 12.980449,
|
||||
15.384750, 14.651885, 14.238700, 14.239028, 14.487102, 14.581562, 14.718998,
|
||||
14.777721, 14.788445, 14.778661, 14.582790, 14.099785, 13.649637, 12.935359,
|
||||
12.201859, 10.891931, 8.482221, 12.980449, 15.384750, 14.651886, 14.238801,
|
||||
14.239434, 14.487303, 14.588010, 14.744860, 14.784773, 14.786094, 14.735647,
|
||||
14.455704, 13.939591, 13.450393, 12.687876, 11.849334, 10.476658, 8.043672,
|
||||
12.980449, 15.384750, 14.651987, 14.245320, 14.265579, 14.493824, 14.588211,
|
||||
14.745312, 14.787263, 14.775934, 14.582036, 14.099475, 13.649563, 12.935358,
|
||||
12.201859, 10.911285, 9.730570, 6.696921, 12.980449, 15.384750, 14.652393,
|
||||
14.271466, 14.370434, 14.520069, 14.589027, 14.746028, 14.785482, 14.735605,
|
||||
14.455693, 13.939590, 13.450393, 12.687876, 11.849334, 10.494514, 9.195398,
|
||||
6.215460, 12.980449, 15.384750, 14.652494, 14.277985, 14.396679, 14.533035,
|
||||
14.615021, 14.754825, 14.775610, 14.582796, 14.099664, 13.649565, 12.935358,
|
||||
12.201859, 10.911285, 9.747361, 7.779960, 5.617541, 12.980448, 15.384731,
|
||||
14.652415, 14.278078, 14.397578, 14.559053, 14.718657, 14.776398, 14.747044,
|
||||
14.504690, 13.951810, 13.450583, 12.687876, 11.849334, 10.494514, 9.210817,
|
||||
7.210003, 5.164575, 12.980446, 15.383448, 14.647073, 14.277541, 14.403813,
|
||||
14.569546, 14.744956, 14.765103, 14.629073, 14.296161, 13.698573, 12.936118,
|
||||
12.201859, 10.911285, 9.747361, 7.790897, 6.322998, 3.931551, 12.981550,
|
||||
15.376916, 14.615597, 14.274820, 14.437479, 14.575942, 14.707492, 14.734111,
|
||||
14.515975, 14.000806, 13.462803, 12.688066, 11.849334, 10.494514, 9.210817,
|
||||
7.219566, 5.781392, 3.486081, 12.991899, 15.376201, 14.579444, 14.296898,
|
||||
14.473361, 14.522910, 14.491600, 14.543267, 14.288580, 13.700311, 12.936579,
|
||||
12.201867, 10.911285, 9.747361, 7.790897, 6.331506, 4.480348, 2.923138,
|
||||
13.019848, 15.383477, 14.582260, 14.385262, 14.452673, 14.436019, 14.238174,
|
||||
14.255993, 13.977481, 13.532342, 12.705591, 11.849605, 10.494514, 9.210817,
|
||||
7.219566, 5.789642, 4.018194, 2.766222, 13.028558, 15.315782, 14.439141,
|
||||
14.326286, 14.452429, 14.311731, 14.033235, 13.922587, 13.665868, 13.207897,
|
||||
12.274375, 10.912967, 9.747371, 7.790897, 6.331506, 4.488594, 3.454993,
|
||||
2.692682, 12.992752, 15.321471, 14.409573, 14.236340, 14.322969, 14.049072,
|
||||
13.764823, 13.479242, 13.250105, 12.759133, 12.019174, 10.532951, 9.211409,
|
||||
7.219566, 5.789642, 4.026440, 3.298077, 2.674624, 12.945493, 15.276596,
|
||||
14.315745, 14.026198, 14.085774, 13.844563, 13.447576, 12.964935, 12.735525,
|
||||
12.288592, 11.511693, 9.900227, 7.793270, 6.331506, 4.488594, 3.463236,
|
||||
3.224318, 2.672433, 12.757570, 15.056661, 14.095011, 13.722362, 13.812624,
|
||||
13.608480, 13.021206, 12.367627, 11.937931, 11.581049, 10.599552, 9.247860,
|
||||
7.220151, 5.789642, 4.026437, 3.305882, 3.191260, 2.615317, 12.581293,
|
||||
14.824658, 13.909074, 13.496158, 13.491402, 13.221550, 12.514140, 11.677229,
|
||||
10.936895, 10.619912, 9.634779, 7.763570, 6.331082, 4.488590, 3.462798,
|
||||
3.216460, 3.076315, 2.373499, 12.283499, 14.455760, 13.890593, 13.427587,
|
||||
13.183783, 12.763833, 11.861006, 10.740618, 9.820756, 9.354945, 8.669862,
|
||||
7.123268, 5.787860, 4.025994, 3.290000, 3.084410, 2.810905, 2.222916,
|
||||
12.010893, 14.300919, 13.986624, 13.484026, 13.025385, 12.224281, 11.064265,
|
||||
9.631040, 8.594396, 8.003736, 7.561587, 6.274418, 4.466637, 3.446574,
|
||||
3.102467, 2.816989, 2.598688, 1.951541, 11.581477, 13.831132, 13.632027,
|
||||
13.380414, 12.807880, 11.665651, 10.218236, 8.562237, 7.222614, 6.611808,
|
||||
6.261676, 5.402793, 3.938544, 3.174375, 2.818166, 2.602758, 2.213911,
|
||||
1.434763, 11.050735, 12.893449, 12.363152, 12.712829, 12.012961, 10.887854,
|
||||
9.109699, 7.421701, 5.965603, 5.272129, 4.991435, 4.423000, 3.369988,
|
||||
2.800371, 2.593901, 2.217431, 1.670917, 1.215265, 10.641194, 11.766277,
|
||||
10.777082, 10.972917, 10.689298, 9.701545, 7.719947, 6.145654, 4.872442,
|
||||
4.099600, 3.880934, 3.514159, 2.786474, 2.368963, 2.162376, 1.673670,
|
||||
1.450770, 1.185424, 10.071964, 11.107701, 9.172361, 8.551313, 8.412080,
|
||||
7.641397, 6.174246, 4.853916, 3.904549, 3.246810, 2.959903, 2.785066,
|
||||
2.240001, 1.793166, 1.585520, 1.449824, 1.405368, 1.168856, 9.213182,
|
||||
9.173278, 7.219231, 6.242951, 5.626013, 5.768007, 4.908666, 3.809589,
|
||||
3.115109, 2.617899, 2.274793, 2.172960, 1.838597, 1.505915, 1.414333,
|
||||
1.392666, 1.338173, 1.105611, 7.365015, 7.471370, 5.622346, 4.520127,
|
||||
3.936272, 4.208822, 3.623024, 2.977794, 2.450003, 2.097261, 1.824090,
|
||||
1.643270, 1.473525, 1.351388, 1.327504, 1.323865, 1.307894, 1.088234,
|
||||
6.198210, 6.580712, 4.682511, 3.416952, 2.941929, 2.766637, 2.650686,
|
||||
2.315439, 1.925838, 1.659784, 1.464419, 1.252806, 1.162722, 1.197518,
|
||||
1.199875, 1.197365, 1.194040, 0.995797, 5.402507, 5.055466, 3.728724,
|
||||
2.624359, 2.165810, 1.943189, 1.918190, 1.738078, 1.516328, 1.290520,
|
||||
1.155793, 1.015962, 0.881900, 0.807203, 0.754242, 0.743378, 0.740288,
|
||||
0.614158, 3.937867, 3.862507, 2.884664, 2.088147, 1.648496, 1.473584,
|
||||
1.340123, 1.291769, 1.165381, 1.000224, 0.893316, 0.821333, 0.691363,
|
||||
0.610501, 0.586766, 0.583762, 0.577840, 0.468733, 3.104660, 3.181078,
|
||||
2.420208, 1.747442, 1.297956, 1.109835, 0.970385, 0.943229, 0.876923,
|
||||
0.777584, 0.678183, 0.628623, 0.553745, 0.523430, 0.519490, 0.514394,
|
||||
0.492259, 0.403172, 2.593833, 2.533720, 2.010452, 1.480944, 1.060302,
|
||||
0.846383, 0.738703, 0.673144, 0.658010, 0.592449, 0.518236, 0.470335,
|
||||
0.425088, 0.393168, 0.378116, 0.355846, 0.275469, 0.213128, 2.176988,
|
||||
2.089575, 1.671284, 1.225008, 0.895382, 0.672008, 0.566241, 0.496746,
|
||||
0.488005, 0.449874, 0.400899, 0.354002, 0.318150, 0.281533, 0.238545,
|
||||
0.224159, 0.202399, 0.160681, 1.874679, 1.769165, 1.430124, 1.068727,
|
||||
0.780272, 0.557801, 0.441643, 0.377256, 0.352957, 0.338452, 0.304965,
|
||||
0.273172, 0.240052, 0.208724, 0.193431, 0.190845, 0.185025, 0.138166,
|
||||
1.590226, 1.502830, 1.193127, 0.917885, 0.670432, 0.474546, 0.355420,
|
||||
0.292305, 0.259035, 0.249937, 0.232079, 0.208943, 0.181936, 0.160038,
|
||||
0.152257, 0.151235, 0.149583, 0.120747, 1.331730, 1.255907, 1.012871,
|
||||
0.778422, 0.578977, 0.412432, 0.293155, 0.231824, 0.197187, 0.183921,
|
||||
0.174876, 0.157252, 0.140263, 0.127050, 0.110244, 0.105041, 0.104323,
|
||||
0.086944, 1.153994, 1.118771, 0.822355, 0.612321, 0.478249, 0.348222,
|
||||
0.247408, 0.186141, 0.152714, 0.135445, 0.129810, 0.119994, 0.115619,
|
||||
0.131626, 0.095612, 0.079343, 0.077502, 0.064550, 0.946317, 0.925894,
|
||||
0.677969, 0.499906, 0.397101, 0.297931, 0.214467, 0.152333, 0.120731,
|
||||
0.102686, 0.095062, 0.090361, 0.122319, 0.240194, 0.112687, 0.070690,
|
||||
0.070461, 0.054194, 0.824155, 0.787241, 0.581856, 0.419228, 0.313167,
|
||||
0.245582, 0.183500, 0.128101, 0.096577, 0.080267, 0.071022, 0.066851,
|
||||
0.085754, 0.154163, 0.075884, 0.052401, 0.054270, 0.026656, 0.716310,
|
||||
0.671378, 0.489580, 0.349569, 0.256155, 0.206343, 0.157853, 0.111950,
|
||||
0.079271, 0.062518, 0.053441, 0.049660, 0.051400, 0.063778, 0.039993,
|
||||
0.029133, 0.023382, 0.013725, 0.614125, 0.579096, 0.417126, 0.299465,
|
||||
0.217849, 0.165515, 0.129040, 0.093127, 0.065612, 0.049543, 0.041429,
|
||||
0.036850, 0.034416, 0.033989, 0.024216, 0.017377, 0.014833, 0.011987,
|
||||
0.520407, 0.487239, 0.349473, 0.251741, 0.184897, 0.135813, 0.107098,
|
||||
0.073607, 0.053938, 0.040531, 0.032931, 0.028876, 0.025759, 0.022168,
|
||||
0.016739, 0.014638, 0.014333, 0.011947, 0.449954, 0.415124, 0.299452,
|
||||
0.216942, 0.158874, 0.115334, 0.088821, 0.060105, 0.042610, 0.032566,
|
||||
0.026903, 0.023123, 0.019913, 0.016835, 0.014306, 0.013625, 0.013535,
|
||||
0.011284, 0.377618, 0.347773, 0.251741, 0.184839, 0.132857, 0.095439,
|
||||
0.070462, 0.052244, 0.036078, 0.026025, 0.021518, 0.018487, 0.015361,
|
||||
0.012905, 0.011470, 0.010569, 0.010283, 0.008297, 0.319953, 0.297976,
|
||||
0.216942, 0.158842, 0.113280, 0.080426, 0.057367, 0.041987, 0.030135,
|
||||
0.022295, 0.017901, 0.015121, 0.012224, 0.010035, 0.009353, 0.009108,
|
||||
0.008695, 0.006139, 0.267864, 0.250502, 0.184839, 0.132851, 0.095039,
|
||||
0.068220, 0.049135, 0.035315, 0.025144, 0.018237, 0.013857, 0.012094,
|
||||
0.009715, 0.007743, 0.006937, 0.006446, 0.006243, 0.004929, 0.230449,
|
||||
0.215895, 0.158842, 0.113280, 0.080417, 0.057174, 0.041304, 0.029959,
|
||||
0.021866, 0.015673, 0.012133, 0.010083, 0.007801, 0.006053, 0.005401,
|
||||
0.003834, 0.003429, 0.002851, 0.193984, 0.183963, 0.132851, 0.095039,
|
||||
0.068220, 0.049133, 0.035305, 0.025140, 0.018150, 0.013175, 0.010422,
|
||||
0.008491, 0.006397, 0.004567, 0.003494, 0.002933, 0.002825, 0.002355,
|
||||
0.167298, 0.158088, 0.113280, 0.080417, 0.057174, 0.041304, 0.029959,
|
||||
0.021866, 0.015669, 0.011955, 0.009257, 0.007051, 0.005543, 0.003905,
|
||||
0.002984, 0.002825, 0.002814, 0.002347, 0.143228, 0.132220, 0.095039,
|
||||
0.068220, 0.049133, 0.035305, 0.025140, 0.018150, 0.013174, 0.010394,
|
||||
0.008403, 0.006661, 0.005378, 0.003545, 0.002876, 0.002818, 0.002814,
|
||||
0.002347, 0.122934, 0.112735, 0.080417, 0.057174, 0.041304, 0.029959,
|
||||
0.021866, 0.015669, 0.011955, 0.009258, 0.007182, 0.006012, 0.003762,
|
||||
0.002866, 0.002739, 0.002788, 0.002810, 0.002347, 0.101934, 0.094569,
|
||||
0.068220, 0.049133, 0.035305, 0.025140, 0.018150, 0.013174, 0.010394,
|
||||
0.008405, 0.006797, 0.005845, 0.003333, 0.002703, 0.002695, 0.002723,
|
||||
0.002781, 0.002343, 0.086702, 0.080014, 0.057174, 0.041304, 0.029959,
|
||||
0.021866, 0.015669, 0.011955, 0.009258, 0.007190, 0.006533, 0.005839,
|
||||
0.003326, 0.002700, 0.002690, 0.002694, 0.002716, 0.002314, 0.073040,
|
||||
0.067886, 0.049133, 0.035305, 0.025140, 0.018150, 0.013174, 0.010394,
|
||||
0.008405, 0.006807, 0.006468, 0.005831, 0.003325, 0.002700, 0.002690,
|
||||
0.002690, 0.002687, 0.002253, 0.061685, 0.056890, 0.041304, 0.029959,
|
||||
0.021866, 0.015669, 0.011955, 0.009258, 0.007190, 0.006542, 0.006360,
|
||||
0.005416, 0.003221, 0.002698, 0.002690, 0.002690, 0.002683, 0.002238,
|
||||
0.052465, 0.048894, 0.035305, 0.025140, 0.018150, 0.013174, 0.010394,
|
||||
0.008405, 0.006807, 0.006472, 0.005943, 0.003748, 0.002805, 0.002692,
|
||||
0.002690, 0.002690, 0.002683, 0.002238, 0.043838, 0.041101, 0.029959,
|
||||
0.021866, 0.015669, 0.011955, 0.009258, 0.007190, 0.006543, 0.006465,
|
||||
0.005839, 0.003333, 0.002702, 0.002690, 0.002690, 0.002690, 0.002683,
|
||||
0.002238, 0.037824, 0.035133, 0.025140, 0.018150, 0.013174, 0.010394,
|
||||
0.008405, 0.006807, 0.006480, 0.006464, 0.005838, 0.003326, 0.002700,
|
||||
0.002690, 0.002690, 0.002690, 0.002683, 0.002238, 0.031865, 0.029815,
|
||||
0.021866, 0.015668, 0.011955, 0.009258, 0.007190, 0.006543, 0.006475,
|
||||
0.006462, 0.005831, 0.003325, 0.002700, 0.002690, 0.002690, 0.002690,
|
||||
0.002683, 0.002238, 0.027150, 0.025016, 0.018128, 0.013083, 0.010371,
|
||||
0.008405, 0.006807, 0.006480, 0.006472, 0.006359, 0.005416, 0.003221,
|
||||
0.002698, 0.002690, 0.002690, 0.002690, 0.002683, 0.002238, 0.023094,
|
||||
0.021760, 0.015577, 0.011590, 0.009167, 0.007188, 0.006543, 0.006475,
|
||||
0.006466, 0.005943, 0.003748, 0.002805, 0.002692, 0.002690, 0.002690,
|
||||
0.002690, 0.002683, 0.002238, 0.019269, 0.018038, 0.013060, 0.010280,
|
||||
0.008382, 0.006806, 0.006480, 0.006474, 0.006464, 0.005839, 0.003333,
|
||||
0.002702, 0.002690, 0.002690, 0.002690, 0.002690, 0.002683, 0.002238,
|
||||
0.016874, 0.015472, 0.011566, 0.009148, 0.007171, 0.006527, 0.006458,
|
||||
0.006457, 0.006447, 0.005823, 0.003318, 0.002693, 0.002683, 0.002683,
|
||||
0.002683, 0.002683, 0.002676, 0.002232, 0.011968, 0.011056, 0.008762,
|
||||
0.007219, 0.005717, 0.005391, 0.005386, 0.005386, 0.005377, 0.004856,
|
||||
0.002767, 0.002246, 0.002238, 0.002238, 0.002238, 0.002238, 0.002232,
|
||||
0.001862,
|
||||
};
|
||||
|
||||
void av1_model_rd_surffit(double xm, double yl, double *rate_f,
|
||||
double *dist_f) {
|
||||
const double x_start = -0.5;
|
||||
const double x_end = 16.5;
|
||||
const double x_step = 1;
|
||||
const double y_start = -15.5;
|
||||
const double y_end = 16.5;
|
||||
const double y_step = 0.5;
|
||||
const double epsilon = 1e-6;
|
||||
const int stride = (int)rint((x_end - x_start) / x_step) + 1;
|
||||
(void)y_end;
|
||||
|
||||
xm = AOMMAX(xm, x_start + x_step + epsilon);
|
||||
xm = AOMMIN(xm, x_end - x_step - epsilon);
|
||||
yl = AOMMAX(yl, y_start + y_step + epsilon);
|
||||
yl = AOMMIN(yl, y_end - y_step - epsilon);
|
||||
|
||||
const double y = (yl - y_start) / y_step;
|
||||
const double x = (xm - x_start) / x_step;
|
||||
|
||||
const int yi = (int)floor(y);
|
||||
const int xi = (int)floor(x);
|
||||
assert(xi > 0);
|
||||
assert(yi > 0);
|
||||
|
||||
const double yo = y - yi;
|
||||
const double xo = x - xi;
|
||||
const double *prate = &interp_rgrid_surf[(yi - 1) * stride + (xi - 1)];
|
||||
const double *pdist = &interp_dgrid_surf[(yi - 1) * stride + (xi - 1)];
|
||||
*rate_f = interp_bicubic(prate, stride, xo, yo);
|
||||
*dist_f = interp_bicubic(pdist, stride, xo, yo);
|
||||
}
|
||||
|
||||
static const double interp_rgrid_curv[65] = {
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 4.759876,
|
||||
8.132086, 13.651828, 21.908271, 33.522054, 48.782376, 71.530983,
|
||||
106.728649, 151.942795, 199.893011, 242.850965, 283.933923, 322.154203,
|
||||
360.684608, 394.801656, 426.879017, 460.234313, 484.103987, 508.261495,
|
||||
536.486763, 558.196737, 586.285894, 614.764511, 634.166333, 647.706472,
|
||||
658.211478, 681.360407, 701.052141, 727.007310, 768.663973, 804.407660,
|
||||
884.627751, 1065.658131, 1238.875214, 1440.185176, 1678.377931, 1962.243390,
|
||||
2300.571467, 2702.152072, 3175.775119, 3730.230519, 4374.308184, 5116.798028,
|
||||
5966.489961, 6932.173897, 8022.639747, 9246.677424, 10613.076839,
|
||||
};
|
||||
|
||||
static const double interp_dgrid_curv[65] = {
|
||||
14.604855, 14.604855, 14.604855, 14.604855, 14.604855, 14.604855, 14.604855,
|
||||
14.604855, 14.604855, 14.604855, 14.604855, 14.604855, 14.555776, 14.533692,
|
||||
14.439920, 14.257791, 13.977230, 13.623229, 13.064884, 12.355411, 11.560773,
|
||||
10.728960, 9.861975, 8.643612, 6.916021, 5.154769, 3.734940, 2.680051,
|
||||
1.925506, 1.408410, 1.042223, 0.767641, 0.565392, 0.420116, 0.310427,
|
||||
0.231711, 0.172999, 0.128293, 0.094992, 0.072171, 0.052972, 0.039354,
|
||||
0.029555, 0.022857, 0.016832, 0.013297, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000, 0.000000,
|
||||
0.000000, 0.000000,
|
||||
};
|
||||
|
||||
void av1_model_rd_curvfit(double xqr, double *rate_f, double *distbysse_f) {
|
||||
const double x_start = -15.5;
|
||||
const double x_end = 16.5;
|
||||
const double x_step = 0.5;
|
||||
const double epsilon = 1e-6;
|
||||
(void)x_end;
|
||||
|
||||
xqr = AOMMAX(xqr, x_start + x_step + epsilon);
|
||||
xqr = AOMMIN(xqr, x_end - x_step - epsilon);
|
||||
const double x = (xqr - x_start) / x_step;
|
||||
const int xi = (int)floor(x);
|
||||
const double xo = x - xi;
|
||||
|
||||
assert(xi > 0);
|
||||
|
||||
const double *prate = &interp_rgrid_curv[(xi - 1)];
|
||||
const double *pdist = &interp_dgrid_curv[(xi - 1)];
|
||||
*rate_f = interp_cubic(prate, xo);
|
||||
*distbysse_f = interp_cubic(pdist, xo);
|
||||
}
|
||||
|
||||
static void get_entropy_contexts_plane(BLOCK_SIZE plane_bsize,
|
||||
const struct macroblockd_plane *pd,
|
||||
ENTROPY_CONTEXT t_above[MAX_MIB_SIZE],
|
||||
|
|
@ -814,8 +1281,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) {
|
|||
rd->thresh_mult[THR_NEARESTG] = 0;
|
||||
}
|
||||
|
||||
rd->thresh_mult[THR_DC] += 1000;
|
||||
|
||||
rd->thresh_mult[THR_NEWMV] += 1000;
|
||||
rd->thresh_mult[THR_NEWL2] += 1000;
|
||||
rd->thresh_mult[THR_NEWL3] += 1000;
|
||||
|
|
@ -840,8 +1305,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) {
|
|||
rd->thresh_mult[THR_GLOBALG] += 2000;
|
||||
rd->thresh_mult[THR_GLOBALA] += 2000;
|
||||
|
||||
rd->thresh_mult[THR_PAETH] += 1000;
|
||||
|
||||
rd->thresh_mult[THR_COMP_NEAREST_NEARESTLA] += 1000;
|
||||
rd->thresh_mult[THR_COMP_NEAREST_NEARESTL2A] += 1000;
|
||||
rd->thresh_mult[THR_COMP_NEAREST_NEARESTL3A] += 1000;
|
||||
|
|
@ -956,15 +1419,6 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) {
|
|||
rd->thresh_mult[THR_COMP_NEW_NEWGA2] += 2000;
|
||||
rd->thresh_mult[THR_COMP_GLOBAL_GLOBALGA2] += 2500;
|
||||
|
||||
rd->thresh_mult[THR_H_PRED] += 2000;
|
||||
rd->thresh_mult[THR_V_PRED] += 2000;
|
||||
rd->thresh_mult[THR_D135_PRED] += 2500;
|
||||
rd->thresh_mult[THR_D203_PRED] += 2500;
|
||||
rd->thresh_mult[THR_D157_PRED] += 2500;
|
||||
rd->thresh_mult[THR_D67_PRED] += 2500;
|
||||
rd->thresh_mult[THR_D113_PRED] += 2500;
|
||||
rd->thresh_mult[THR_D45_PRED] += 2500;
|
||||
|
||||
rd->thresh_mult[THR_COMP_NEAR_NEARLL2] += 1600;
|
||||
rd->thresh_mult[THR_COMP_NEAREST_NEWLL2] += 2000;
|
||||
rd->thresh_mult[THR_COMP_NEW_NEARESTLL2] += 2000;
|
||||
|
|
@ -996,6 +1450,20 @@ void av1_set_rd_speed_thresholds(AV1_COMP *cpi) {
|
|||
rd->thresh_mult[THR_COMP_NEW_NEARBA] += 2200;
|
||||
rd->thresh_mult[THR_COMP_NEW_NEWBA] += 2400;
|
||||
rd->thresh_mult[THR_COMP_GLOBAL_GLOBALBA] += 3200;
|
||||
|
||||
rd->thresh_mult[THR_DC] += 1000;
|
||||
rd->thresh_mult[THR_PAETH] += 1000;
|
||||
rd->thresh_mult[THR_SMOOTH] += 2000;
|
||||
rd->thresh_mult[THR_SMOOTH_V] += 2000;
|
||||
rd->thresh_mult[THR_SMOOTH_H] += 2000;
|
||||
rd->thresh_mult[THR_H_PRED] += 2000;
|
||||
rd->thresh_mult[THR_V_PRED] += 2000;
|
||||
rd->thresh_mult[THR_D135_PRED] += 2500;
|
||||
rd->thresh_mult[THR_D203_PRED] += 2500;
|
||||
rd->thresh_mult[THR_D157_PRED] += 2500;
|
||||
rd->thresh_mult[THR_D67_PRED] += 2500;
|
||||
rd->thresh_mult[THR_D113_PRED] += 2500;
|
||||
rd->thresh_mult[THR_D45_PRED] += 2500;
|
||||
}
|
||||
|
||||
void av1_set_rd_speed_thresholds_sub8x8(AV1_COMP *cpi) {
|
||||
|
|
|
|||
48
third_party/aom/av1/encoder/rd.h
vendored
48
third_party/aom/av1/encoder/rd.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_RD_H_
|
||||
#define AV1_ENCODER_RD_H_
|
||||
#ifndef AOM_AV1_ENCODER_RD_H_
|
||||
#define AOM_AV1_ENCODER_RD_H_
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
|
|
@ -57,8 +57,6 @@ typedef enum {
|
|||
THR_NEARESTA,
|
||||
THR_NEARESTG,
|
||||
|
||||
THR_DC,
|
||||
|
||||
THR_NEWMV,
|
||||
THR_NEWL2,
|
||||
THR_NEWL3,
|
||||
|
|
@ -100,12 +98,6 @@ typedef enum {
|
|||
THR_COMP_NEAREST_NEARESTLG,
|
||||
THR_COMP_NEAREST_NEARESTBA,
|
||||
|
||||
THR_PAETH,
|
||||
|
||||
THR_SMOOTH,
|
||||
THR_SMOOTH_V,
|
||||
THR_SMOOTH_H,
|
||||
|
||||
THR_COMP_NEAR_NEARLA,
|
||||
THR_COMP_NEW_NEARESTLA,
|
||||
THR_COMP_NEAREST_NEWLA,
|
||||
|
|
@ -202,15 +194,6 @@ typedef enum {
|
|||
THR_COMP_NEW_NEWGA2,
|
||||
THR_COMP_GLOBAL_GLOBALGA2,
|
||||
|
||||
THR_H_PRED,
|
||||
THR_V_PRED,
|
||||
THR_D135_PRED,
|
||||
THR_D203_PRED,
|
||||
THR_D157_PRED,
|
||||
THR_D67_PRED,
|
||||
THR_D113_PRED,
|
||||
THR_D45_PRED,
|
||||
|
||||
THR_COMP_NEAR_NEARLL2,
|
||||
THR_COMP_NEW_NEARESTLL2,
|
||||
THR_COMP_NEAREST_NEWLL2,
|
||||
|
|
@ -243,7 +226,26 @@ typedef enum {
|
|||
THR_COMP_NEW_NEWBA,
|
||||
THR_COMP_GLOBAL_GLOBALBA,
|
||||
|
||||
MAX_MODES
|
||||
THR_DC,
|
||||
THR_PAETH,
|
||||
THR_SMOOTH,
|
||||
THR_SMOOTH_V,
|
||||
THR_SMOOTH_H,
|
||||
THR_H_PRED,
|
||||
THR_V_PRED,
|
||||
THR_D135_PRED,
|
||||
THR_D203_PRED,
|
||||
THR_D157_PRED,
|
||||
THR_D67_PRED,
|
||||
THR_D113_PRED,
|
||||
THR_D45_PRED,
|
||||
|
||||
MAX_MODES,
|
||||
|
||||
LAST_SINGLE_REF_MODES = THR_GLOBALG,
|
||||
MAX_SINGLE_REF_MODES = LAST_SINGLE_REF_MODES + 1,
|
||||
LAST_COMP_REF_MODES = THR_COMP_GLOBAL_GLOBALBA,
|
||||
MAX_COMP_REF_MODES = LAST_COMP_REF_MODES + 1
|
||||
} THR_MODES;
|
||||
|
||||
typedef enum {
|
||||
|
|
@ -392,6 +394,10 @@ void av1_initialize_me_consts(const struct AV1_COMP *cpi, MACROBLOCK *x,
|
|||
void av1_model_rd_from_var_lapndz(int64_t var, unsigned int n,
|
||||
unsigned int qstep, int *rate, int64_t *dist);
|
||||
|
||||
void av1_model_rd_curvfit(double xqr, double *rate_f, double *distbysse_f);
|
||||
void av1_model_rd_surffit(double xm, double yl, double *rate_f,
|
||||
double *distbysse_f);
|
||||
|
||||
int av1_get_switchable_rate(const AV1_COMMON *const cm, MACROBLOCK *x,
|
||||
const MACROBLOCKD *xd);
|
||||
|
||||
|
|
@ -455,4 +461,4 @@ void av1_fill_coeff_costs(MACROBLOCK *x, FRAME_CONTEXT *fc,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_RD_H_
|
||||
#endif // AOM_AV1_ENCODER_RD_H_
|
||||
|
|
|
|||
4573
third_party/aom/av1/encoder/rdopt.c
vendored
4573
third_party/aom/av1/encoder/rdopt.c
vendored
File diff suppressed because it is too large
Load diff
18
third_party/aom/av1/encoder/rdopt.h
vendored
18
third_party/aom/av1/encoder/rdopt.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_RDOPT_H_
|
||||
#define AV1_ENCODER_RDOPT_H_
|
||||
#ifndef AOM_AV1_ENCODER_RDOPT_H_
|
||||
#define AOM_AV1_ENCODER_RDOPT_H_
|
||||
|
||||
#include "av1/common/blockd.h"
|
||||
#include "av1/common/txb_common.h"
|
||||
|
|
@ -25,6 +25,10 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#define MAX_REF_MV_SERCH 3
|
||||
#define DEFAULT_LUMA_INTERP_SKIP_FLAG 1
|
||||
#define DEFAULT_CHROMA_INTERP_SKIP_FLAG 2
|
||||
#define DEFAULT_INTERP_SKIP_FLAG \
|
||||
(DEFAULT_LUMA_INTERP_SKIP_FLAG | DEFAULT_CHROMA_INTERP_SKIP_FLAG)
|
||||
|
||||
struct TileInfo;
|
||||
struct macroblock;
|
||||
|
|
@ -111,7 +115,7 @@ unsigned int av1_high_get_sby_perpixel_variance(const struct AV1_COMP *cpi,
|
|||
const struct buf_2d *ref,
|
||||
BLOCK_SIZE bs, int bd);
|
||||
|
||||
void av1_rd_pick_inter_mode_sb(const struct AV1_COMP *cpi,
|
||||
void av1_rd_pick_inter_mode_sb(struct AV1_COMP *cpi,
|
||||
struct TileDataEnc *tile_data,
|
||||
struct macroblock *x, int mi_row, int mi_col,
|
||||
struct RD_STATS *rd_cost, BLOCK_SIZE bsize,
|
||||
|
|
@ -123,14 +127,12 @@ void av1_rd_pick_inter_mode_sb_seg_skip(
|
|||
BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, int64_t best_rd_so_far);
|
||||
|
||||
#if CONFIG_COLLECT_INTER_MODE_RD_STATS
|
||||
#define INTER_MODE_RD_TEST 0
|
||||
void av1_inter_mode_data_init();
|
||||
void av1_inter_mode_data_fit(int rdmult);
|
||||
void av1_inter_mode_data_show(const AV1_COMMON *cm);
|
||||
void av1_inter_mode_data_init(struct TileDataEnc *tile_data);
|
||||
void av1_inter_mode_data_fit(TileDataEnc *tile_data, int rdmult);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_RDOPT_H_
|
||||
#endif // AOM_AV1_ENCODER_RDOPT_H_
|
||||
|
|
|
|||
627
third_party/aom/av1/encoder/reconinter_enc.c
vendored
Normal file
627
third_party/aom/av1/encoder/reconinter_enc.c
vendored
Normal file
|
|
@ -0,0 +1,627 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "config/aom_config.h"
|
||||
#include "config/aom_dsp_rtcd.h"
|
||||
#include "config/aom_scale_rtcd.h"
|
||||
|
||||
#include "aom/aom_integer.h"
|
||||
#include "aom_dsp/blend.h"
|
||||
|
||||
#include "av1/common/blockd.h"
|
||||
#include "av1/common/mvref_common.h"
|
||||
#include "av1/common/reconinter.h"
|
||||
#include "av1/common/reconintra.h"
|
||||
#include "av1/common/onyxc_int.h"
|
||||
#include "av1/common/obmc.h"
|
||||
#include "av1/encoder/reconinter_enc.h"
|
||||
|
||||
static INLINE void calc_subpel_params(
|
||||
MACROBLOCKD *xd, const struct scale_factors *const sf, const MV mv,
|
||||
int plane, const int pre_x, const int pre_y, int x, int y,
|
||||
struct buf_2d *const pre_buf, uint8_t **pre, SubpelParams *subpel_params,
|
||||
int bw, int bh) {
|
||||
struct macroblockd_plane *const pd = &xd->plane[plane];
|
||||
const int is_scaled = av1_is_scaled(sf);
|
||||
if (is_scaled) {
|
||||
int ssx = pd->subsampling_x;
|
||||
int ssy = pd->subsampling_y;
|
||||
int orig_pos_y = (pre_y + y) << SUBPEL_BITS;
|
||||
orig_pos_y += mv.row * (1 << (1 - ssy));
|
||||
int orig_pos_x = (pre_x + x) << SUBPEL_BITS;
|
||||
orig_pos_x += mv.col * (1 << (1 - ssx));
|
||||
int pos_y = sf->scale_value_y(orig_pos_y, sf);
|
||||
int pos_x = sf->scale_value_x(orig_pos_x, sf);
|
||||
pos_x += SCALE_EXTRA_OFF;
|
||||
pos_y += SCALE_EXTRA_OFF;
|
||||
|
||||
const int top = -AOM_LEFT_TOP_MARGIN_SCALED(ssy);
|
||||
const int left = -AOM_LEFT_TOP_MARGIN_SCALED(ssx);
|
||||
const int bottom = (pre_buf->height + AOM_INTERP_EXTEND)
|
||||
<< SCALE_SUBPEL_BITS;
|
||||
const int right = (pre_buf->width + AOM_INTERP_EXTEND) << SCALE_SUBPEL_BITS;
|
||||
pos_y = clamp(pos_y, top, bottom);
|
||||
pos_x = clamp(pos_x, left, right);
|
||||
|
||||
*pre = pre_buf->buf0 + (pos_y >> SCALE_SUBPEL_BITS) * pre_buf->stride +
|
||||
(pos_x >> SCALE_SUBPEL_BITS);
|
||||
subpel_params->subpel_x = pos_x & SCALE_SUBPEL_MASK;
|
||||
subpel_params->subpel_y = pos_y & SCALE_SUBPEL_MASK;
|
||||
subpel_params->xs = sf->x_step_q4;
|
||||
subpel_params->ys = sf->y_step_q4;
|
||||
} else {
|
||||
const MV mv_q4 = clamp_mv_to_umv_border_sb(
|
||||
xd, &mv, bw, bh, pd->subsampling_x, pd->subsampling_y);
|
||||
subpel_params->xs = subpel_params->ys = SCALE_SUBPEL_SHIFTS;
|
||||
subpel_params->subpel_x = (mv_q4.col & SUBPEL_MASK) << SCALE_EXTRA_BITS;
|
||||
subpel_params->subpel_y = (mv_q4.row & SUBPEL_MASK) << SCALE_EXTRA_BITS;
|
||||
*pre = pre_buf->buf + (y + (mv_q4.row >> SUBPEL_BITS)) * pre_buf->stride +
|
||||
(x + (mv_q4.col >> SUBPEL_BITS));
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void build_inter_predictors(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int plane, const MB_MODE_INFO *mi,
|
||||
int build_for_obmc, int bw, int bh,
|
||||
int mi_x, int mi_y) {
|
||||
struct macroblockd_plane *const pd = &xd->plane[plane];
|
||||
int is_compound = has_second_ref(mi);
|
||||
int ref;
|
||||
const int is_intrabc = is_intrabc_block(mi);
|
||||
assert(IMPLIES(is_intrabc, !is_compound));
|
||||
int is_global[2] = { 0, 0 };
|
||||
for (ref = 0; ref < 1 + is_compound; ++ref) {
|
||||
const WarpedMotionParams *const wm = &xd->global_motion[mi->ref_frame[ref]];
|
||||
is_global[ref] = is_global_mv_block(mi, wm->wmtype);
|
||||
}
|
||||
|
||||
const BLOCK_SIZE bsize = mi->sb_type;
|
||||
const int ss_x = pd->subsampling_x;
|
||||
const int ss_y = pd->subsampling_y;
|
||||
int sub8x8_inter = (block_size_wide[bsize] < 8 && ss_x) ||
|
||||
(block_size_high[bsize] < 8 && ss_y);
|
||||
|
||||
if (is_intrabc) sub8x8_inter = 0;
|
||||
|
||||
// For sub8x8 chroma blocks, we may be covering more than one luma block's
|
||||
// worth of pixels. Thus (mi_x, mi_y) may not be the correct coordinates for
|
||||
// the top-left corner of the prediction source - the correct top-left corner
|
||||
// is at (pre_x, pre_y).
|
||||
const int row_start =
|
||||
(block_size_high[bsize] == 4) && ss_y && !build_for_obmc ? -1 : 0;
|
||||
const int col_start =
|
||||
(block_size_wide[bsize] == 4) && ss_x && !build_for_obmc ? -1 : 0;
|
||||
const int pre_x = (mi_x + MI_SIZE * col_start) >> ss_x;
|
||||
const int pre_y = (mi_y + MI_SIZE * row_start) >> ss_y;
|
||||
|
||||
sub8x8_inter = sub8x8_inter && !build_for_obmc;
|
||||
if (sub8x8_inter) {
|
||||
for (int row = row_start; row <= 0 && sub8x8_inter; ++row) {
|
||||
for (int col = col_start; col <= 0; ++col) {
|
||||
const MB_MODE_INFO *this_mbmi = xd->mi[row * xd->mi_stride + col];
|
||||
if (!is_inter_block(this_mbmi)) sub8x8_inter = 0;
|
||||
if (is_intrabc_block(this_mbmi)) sub8x8_inter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sub8x8_inter) {
|
||||
// block size
|
||||
const int b4_w = block_size_wide[bsize] >> ss_x;
|
||||
const int b4_h = block_size_high[bsize] >> ss_y;
|
||||
const BLOCK_SIZE plane_bsize = scale_chroma_bsize(bsize, ss_x, ss_y);
|
||||
const int b8_w = block_size_wide[plane_bsize] >> ss_x;
|
||||
const int b8_h = block_size_high[plane_bsize] >> ss_y;
|
||||
assert(!is_compound);
|
||||
|
||||
const struct buf_2d orig_pred_buf[2] = { pd->pre[0], pd->pre[1] };
|
||||
|
||||
int row = row_start;
|
||||
for (int y = 0; y < b8_h; y += b4_h) {
|
||||
int col = col_start;
|
||||
for (int x = 0; x < b8_w; x += b4_w) {
|
||||
MB_MODE_INFO *this_mbmi = xd->mi[row * xd->mi_stride + col];
|
||||
is_compound = has_second_ref(this_mbmi);
|
||||
int tmp_dst_stride = 8;
|
||||
assert(bw < 8 || bh < 8);
|
||||
ConvolveParams conv_params = get_conv_params_no_round(
|
||||
0, plane, xd->tmp_conv_dst, tmp_dst_stride, is_compound, xd->bd);
|
||||
conv_params.use_jnt_comp_avg = 0;
|
||||
struct buf_2d *const dst_buf = &pd->dst;
|
||||
uint8_t *dst = dst_buf->buf + dst_buf->stride * y + x;
|
||||
|
||||
ref = 0;
|
||||
const RefBuffer *ref_buf =
|
||||
&cm->frame_refs[this_mbmi->ref_frame[ref] - LAST_FRAME];
|
||||
|
||||
pd->pre[ref].buf0 =
|
||||
(plane == 1) ? ref_buf->buf->u_buffer : ref_buf->buf->v_buffer;
|
||||
pd->pre[ref].buf =
|
||||
pd->pre[ref].buf0 + scaled_buffer_offset(pre_x, pre_y,
|
||||
ref_buf->buf->uv_stride,
|
||||
&ref_buf->sf);
|
||||
pd->pre[ref].width = ref_buf->buf->uv_crop_width;
|
||||
pd->pre[ref].height = ref_buf->buf->uv_crop_height;
|
||||
pd->pre[ref].stride = ref_buf->buf->uv_stride;
|
||||
|
||||
const struct scale_factors *const sf =
|
||||
is_intrabc ? &cm->sf_identity : &ref_buf->sf;
|
||||
struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];
|
||||
|
||||
const MV mv = this_mbmi->mv[ref].as_mv;
|
||||
|
||||
uint8_t *pre;
|
||||
SubpelParams subpel_params;
|
||||
WarpTypesAllowed warp_types;
|
||||
warp_types.global_warp_allowed = is_global[ref];
|
||||
warp_types.local_warp_allowed = this_mbmi->motion_mode == WARPED_CAUSAL;
|
||||
|
||||
calc_subpel_params(xd, sf, mv, plane, pre_x, pre_y, x, y, pre_buf, &pre,
|
||||
&subpel_params, bw, bh);
|
||||
conv_params.do_average = ref;
|
||||
if (is_masked_compound_type(mi->interinter_comp.type)) {
|
||||
// masked compound type has its own average mechanism
|
||||
conv_params.do_average = 0;
|
||||
}
|
||||
|
||||
av1_make_inter_predictor(
|
||||
pre, pre_buf->stride, dst, dst_buf->stride, &subpel_params, sf,
|
||||
b4_w, b4_h, &conv_params, this_mbmi->interp_filters, &warp_types,
|
||||
(mi_x >> pd->subsampling_x) + x, (mi_y >> pd->subsampling_y) + y,
|
||||
plane, ref, mi, build_for_obmc, xd, cm->allow_warped_motion);
|
||||
|
||||
++col;
|
||||
}
|
||||
++row;
|
||||
}
|
||||
|
||||
for (ref = 0; ref < 2; ++ref) pd->pre[ref] = orig_pred_buf[ref];
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
ConvolveParams conv_params = get_conv_params_no_round(
|
||||
0, plane, xd->tmp_conv_dst, MAX_SB_SIZE, is_compound, xd->bd);
|
||||
av1_jnt_comp_weight_assign(cm, mi, 0, &conv_params.fwd_offset,
|
||||
&conv_params.bck_offset,
|
||||
&conv_params.use_jnt_comp_avg, is_compound);
|
||||
|
||||
struct buf_2d *const dst_buf = &pd->dst;
|
||||
uint8_t *const dst = dst_buf->buf;
|
||||
for (ref = 0; ref < 1 + is_compound; ++ref) {
|
||||
const struct scale_factors *const sf =
|
||||
is_intrabc ? &cm->sf_identity : &xd->block_refs[ref]->sf;
|
||||
struct buf_2d *const pre_buf = is_intrabc ? dst_buf : &pd->pre[ref];
|
||||
const MV mv = mi->mv[ref].as_mv;
|
||||
|
||||
uint8_t *pre;
|
||||
SubpelParams subpel_params;
|
||||
calc_subpel_params(xd, sf, mv, plane, pre_x, pre_y, 0, 0, pre_buf, &pre,
|
||||
&subpel_params, bw, bh);
|
||||
|
||||
WarpTypesAllowed warp_types;
|
||||
warp_types.global_warp_allowed = is_global[ref];
|
||||
warp_types.local_warp_allowed = mi->motion_mode == WARPED_CAUSAL;
|
||||
|
||||
if (ref && is_masked_compound_type(mi->interinter_comp.type)) {
|
||||
// masked compound type has its own average mechanism
|
||||
conv_params.do_average = 0;
|
||||
av1_make_masked_inter_predictor(
|
||||
pre, pre_buf->stride, dst, dst_buf->stride, &subpel_params, sf, bw,
|
||||
bh, &conv_params, mi->interp_filters, plane, &warp_types,
|
||||
mi_x >> pd->subsampling_x, mi_y >> pd->subsampling_y, ref, xd,
|
||||
cm->allow_warped_motion);
|
||||
} else {
|
||||
conv_params.do_average = ref;
|
||||
av1_make_inter_predictor(
|
||||
pre, pre_buf->stride, dst, dst_buf->stride, &subpel_params, sf, bw,
|
||||
bh, &conv_params, mi->interp_filters, &warp_types,
|
||||
mi_x >> pd->subsampling_x, mi_y >> pd->subsampling_y, plane, ref,
|
||||
mi, build_for_obmc, xd, cm->allow_warped_motion);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void build_inter_predictors_for_planes(const AV1_COMMON *cm,
|
||||
MACROBLOCKD *xd, BLOCK_SIZE bsize,
|
||||
int mi_row, int mi_col,
|
||||
int plane_from, int plane_to) {
|
||||
int plane;
|
||||
const int mi_x = mi_col * MI_SIZE;
|
||||
const int mi_y = mi_row * MI_SIZE;
|
||||
for (plane = plane_from; plane <= plane_to; ++plane) {
|
||||
const struct macroblockd_plane *pd = &xd->plane[plane];
|
||||
const int bw = pd->width;
|
||||
const int bh = pd->height;
|
||||
|
||||
if (!is_chroma_reference(mi_row, mi_col, bsize, pd->subsampling_x,
|
||||
pd->subsampling_y))
|
||||
continue;
|
||||
|
||||
build_inter_predictors(cm, xd, plane, xd->mi[0], 0, bw, bh, mi_x, mi_y);
|
||||
}
|
||||
}
|
||||
|
||||
void av1_build_inter_predictors_sby(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col, BUFFER_SET *ctx,
|
||||
BLOCK_SIZE bsize) {
|
||||
av1_build_inter_predictors_sbp(cm, xd, mi_row, mi_col, ctx, bsize, 0);
|
||||
}
|
||||
|
||||
void av1_build_inter_predictors_sbuv(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col, BUFFER_SET *ctx,
|
||||
BLOCK_SIZE bsize) {
|
||||
for (int plane_idx = 1; plane_idx < MAX_MB_PLANE; plane_idx++) {
|
||||
av1_build_inter_predictors_sbp(cm, xd, mi_row, mi_col, ctx, bsize,
|
||||
plane_idx);
|
||||
}
|
||||
}
|
||||
|
||||
void av1_build_inter_predictors_sbp(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col, BUFFER_SET *ctx,
|
||||
BLOCK_SIZE bsize, int plane_idx) {
|
||||
build_inter_predictors_for_planes(cm, xd, bsize, mi_row, mi_col, plane_idx,
|
||||
plane_idx);
|
||||
|
||||
if (is_interintra_pred(xd->mi[0])) {
|
||||
BUFFER_SET default_ctx = { { NULL, NULL, NULL }, { 0, 0, 0 } };
|
||||
if (!ctx) {
|
||||
default_ctx.plane[plane_idx] = xd->plane[plane_idx].dst.buf;
|
||||
default_ctx.stride[plane_idx] = xd->plane[plane_idx].dst.stride;
|
||||
ctx = &default_ctx;
|
||||
}
|
||||
av1_build_interintra_predictors_sbp(cm, xd, xd->plane[plane_idx].dst.buf,
|
||||
xd->plane[plane_idx].dst.stride, ctx,
|
||||
plane_idx, bsize);
|
||||
}
|
||||
}
|
||||
|
||||
void av1_build_inter_predictors_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col, BUFFER_SET *ctx,
|
||||
BLOCK_SIZE bsize) {
|
||||
const int num_planes = av1_num_planes(cm);
|
||||
av1_build_inter_predictors_sby(cm, xd, mi_row, mi_col, ctx, bsize);
|
||||
if (num_planes > 1)
|
||||
av1_build_inter_predictors_sbuv(cm, xd, mi_row, mi_col, ctx, bsize);
|
||||
}
|
||||
|
||||
// TODO(sarahparker):
|
||||
// av1_build_inter_predictor should be combined with
|
||||
// av1_make_inter_predictor
|
||||
void av1_build_inter_predictor(const uint8_t *src, int src_stride, uint8_t *dst,
|
||||
int dst_stride, const MV *src_mv,
|
||||
const struct scale_factors *sf, int w, int h,
|
||||
ConvolveParams *conv_params,
|
||||
InterpFilters interp_filters,
|
||||
const WarpTypesAllowed *warp_types, int p_col,
|
||||
int p_row, int plane, int ref,
|
||||
enum mv_precision precision, int x, int y,
|
||||
const MACROBLOCKD *xd, int can_use_previous) {
|
||||
const int is_q4 = precision == MV_PRECISION_Q4;
|
||||
const MV mv_q4 = { is_q4 ? src_mv->row : src_mv->row * 2,
|
||||
is_q4 ? src_mv->col : src_mv->col * 2 };
|
||||
MV32 mv = av1_scale_mv(&mv_q4, x, y, sf);
|
||||
mv.col += SCALE_EXTRA_OFF;
|
||||
mv.row += SCALE_EXTRA_OFF;
|
||||
|
||||
const SubpelParams subpel_params = { sf->x_step_q4, sf->y_step_q4,
|
||||
mv.col & SCALE_SUBPEL_MASK,
|
||||
mv.row & SCALE_SUBPEL_MASK };
|
||||
src += (mv.row >> SCALE_SUBPEL_BITS) * src_stride +
|
||||
(mv.col >> SCALE_SUBPEL_BITS);
|
||||
|
||||
av1_make_inter_predictor(src, src_stride, dst, dst_stride, &subpel_params, sf,
|
||||
w, h, conv_params, interp_filters, warp_types, p_col,
|
||||
p_row, plane, ref, xd->mi[0], 0, xd,
|
||||
can_use_previous);
|
||||
}
|
||||
|
||||
static INLINE void build_prediction_by_above_pred(
|
||||
MACROBLOCKD *xd, int rel_mi_col, uint8_t above_mi_width,
|
||||
MB_MODE_INFO *above_mbmi, void *fun_ctxt, const int num_planes) {
|
||||
struct build_prediction_ctxt *ctxt = (struct build_prediction_ctxt *)fun_ctxt;
|
||||
const int above_mi_col = ctxt->mi_col + rel_mi_col;
|
||||
int mi_x, mi_y;
|
||||
MB_MODE_INFO backup_mbmi = *above_mbmi;
|
||||
|
||||
av1_setup_build_prediction_by_above_pred(xd, rel_mi_col, above_mi_width,
|
||||
above_mbmi, ctxt, num_planes);
|
||||
mi_x = above_mi_col << MI_SIZE_LOG2;
|
||||
mi_y = ctxt->mi_row << MI_SIZE_LOG2;
|
||||
|
||||
const BLOCK_SIZE bsize = xd->mi[0]->sb_type;
|
||||
|
||||
for (int j = 0; j < num_planes; ++j) {
|
||||
const struct macroblockd_plane *pd = &xd->plane[j];
|
||||
int bw = (above_mi_width * MI_SIZE) >> pd->subsampling_x;
|
||||
int bh = clamp(block_size_high[bsize] >> (pd->subsampling_y + 1), 4,
|
||||
block_size_high[BLOCK_64X64] >> (pd->subsampling_y + 1));
|
||||
|
||||
if (av1_skip_u4x4_pred_in_obmc(bsize, pd, 0)) continue;
|
||||
build_inter_predictors(ctxt->cm, xd, j, above_mbmi, 1, bw, bh, mi_x, mi_y);
|
||||
}
|
||||
*above_mbmi = backup_mbmi;
|
||||
}
|
||||
|
||||
void av1_build_prediction_by_above_preds(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col,
|
||||
uint8_t *tmp_buf[MAX_MB_PLANE],
|
||||
int tmp_width[MAX_MB_PLANE],
|
||||
int tmp_height[MAX_MB_PLANE],
|
||||
int tmp_stride[MAX_MB_PLANE]) {
|
||||
if (!xd->up_available) return;
|
||||
|
||||
// Adjust mb_to_bottom_edge to have the correct value for the OBMC
|
||||
// prediction block. This is half the height of the original block,
|
||||
// except for 128-wide blocks, where we only use a height of 32.
|
||||
int this_height = xd->n4_h * MI_SIZE;
|
||||
int pred_height = AOMMIN(this_height / 2, 32);
|
||||
xd->mb_to_bottom_edge += (this_height - pred_height) * 8;
|
||||
|
||||
struct build_prediction_ctxt ctxt = { cm, mi_row,
|
||||
mi_col, tmp_buf,
|
||||
tmp_width, tmp_height,
|
||||
tmp_stride, xd->mb_to_right_edge };
|
||||
BLOCK_SIZE bsize = xd->mi[0]->sb_type;
|
||||
foreach_overlappable_nb_above(cm, xd, mi_col,
|
||||
max_neighbor_obmc[mi_size_wide_log2[bsize]],
|
||||
build_prediction_by_above_pred, &ctxt);
|
||||
|
||||
xd->mb_to_left_edge = -((mi_col * MI_SIZE) * 8);
|
||||
xd->mb_to_right_edge = ctxt.mb_to_far_edge;
|
||||
xd->mb_to_bottom_edge -= (this_height - pred_height) * 8;
|
||||
}
|
||||
|
||||
static INLINE void build_prediction_by_left_pred(
|
||||
MACROBLOCKD *xd, int rel_mi_row, uint8_t left_mi_height,
|
||||
MB_MODE_INFO *left_mbmi, void *fun_ctxt, const int num_planes) {
|
||||
struct build_prediction_ctxt *ctxt = (struct build_prediction_ctxt *)fun_ctxt;
|
||||
const int left_mi_row = ctxt->mi_row + rel_mi_row;
|
||||
int mi_x, mi_y;
|
||||
MB_MODE_INFO backup_mbmi = *left_mbmi;
|
||||
|
||||
av1_setup_build_prediction_by_left_pred(xd, rel_mi_row, left_mi_height,
|
||||
left_mbmi, ctxt, num_planes);
|
||||
mi_x = ctxt->mi_col << MI_SIZE_LOG2;
|
||||
mi_y = left_mi_row << MI_SIZE_LOG2;
|
||||
const BLOCK_SIZE bsize = xd->mi[0]->sb_type;
|
||||
|
||||
for (int j = 0; j < num_planes; ++j) {
|
||||
const struct macroblockd_plane *pd = &xd->plane[j];
|
||||
int bw = clamp(block_size_wide[bsize] >> (pd->subsampling_x + 1), 4,
|
||||
block_size_wide[BLOCK_64X64] >> (pd->subsampling_x + 1));
|
||||
int bh = (left_mi_height << MI_SIZE_LOG2) >> pd->subsampling_y;
|
||||
|
||||
if (av1_skip_u4x4_pred_in_obmc(bsize, pd, 1)) continue;
|
||||
build_inter_predictors(ctxt->cm, xd, j, left_mbmi, 1, bw, bh, mi_x, mi_y);
|
||||
}
|
||||
*left_mbmi = backup_mbmi;
|
||||
}
|
||||
|
||||
void av1_build_prediction_by_left_preds(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col,
|
||||
uint8_t *tmp_buf[MAX_MB_PLANE],
|
||||
int tmp_width[MAX_MB_PLANE],
|
||||
int tmp_height[MAX_MB_PLANE],
|
||||
int tmp_stride[MAX_MB_PLANE]) {
|
||||
if (!xd->left_available) return;
|
||||
|
||||
// Adjust mb_to_right_edge to have the correct value for the OBMC
|
||||
// prediction block. This is half the width of the original block,
|
||||
// except for 128-wide blocks, where we only use a width of 32.
|
||||
int this_width = xd->n4_w * MI_SIZE;
|
||||
int pred_width = AOMMIN(this_width / 2, 32);
|
||||
xd->mb_to_right_edge += (this_width - pred_width) * 8;
|
||||
|
||||
struct build_prediction_ctxt ctxt = { cm, mi_row,
|
||||
mi_col, tmp_buf,
|
||||
tmp_width, tmp_height,
|
||||
tmp_stride, xd->mb_to_bottom_edge };
|
||||
BLOCK_SIZE bsize = xd->mi[0]->sb_type;
|
||||
foreach_overlappable_nb_left(cm, xd, mi_row,
|
||||
max_neighbor_obmc[mi_size_high_log2[bsize]],
|
||||
build_prediction_by_left_pred, &ctxt);
|
||||
|
||||
xd->mb_to_top_edge = -((mi_row * MI_SIZE) * 8);
|
||||
xd->mb_to_right_edge -= (this_width - pred_width) * 8;
|
||||
xd->mb_to_bottom_edge = ctxt.mb_to_far_edge;
|
||||
}
|
||||
|
||||
void av1_build_obmc_inter_predictors_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col) {
|
||||
const int num_planes = av1_num_planes(cm);
|
||||
uint8_t *dst_buf1[MAX_MB_PLANE], *dst_buf2[MAX_MB_PLANE];
|
||||
int dst_stride1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
|
||||
int dst_stride2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
|
||||
int dst_width1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
|
||||
int dst_width2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
|
||||
int dst_height1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
|
||||
int dst_height2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
|
||||
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||
int len = sizeof(uint16_t);
|
||||
dst_buf1[0] = CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[0]);
|
||||
dst_buf1[1] =
|
||||
CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[0] + MAX_SB_SQUARE * len);
|
||||
dst_buf1[2] =
|
||||
CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[0] + MAX_SB_SQUARE * 2 * len);
|
||||
dst_buf2[0] = CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[1]);
|
||||
dst_buf2[1] =
|
||||
CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[1] + MAX_SB_SQUARE * len);
|
||||
dst_buf2[2] =
|
||||
CONVERT_TO_BYTEPTR(xd->tmp_obmc_bufs[1] + MAX_SB_SQUARE * 2 * len);
|
||||
} else {
|
||||
dst_buf1[0] = xd->tmp_obmc_bufs[0];
|
||||
dst_buf1[1] = xd->tmp_obmc_bufs[0] + MAX_SB_SQUARE;
|
||||
dst_buf1[2] = xd->tmp_obmc_bufs[0] + MAX_SB_SQUARE * 2;
|
||||
dst_buf2[0] = xd->tmp_obmc_bufs[1];
|
||||
dst_buf2[1] = xd->tmp_obmc_bufs[1] + MAX_SB_SQUARE;
|
||||
dst_buf2[2] = xd->tmp_obmc_bufs[1] + MAX_SB_SQUARE * 2;
|
||||
}
|
||||
av1_build_prediction_by_above_preds(cm, xd, mi_row, mi_col, dst_buf1,
|
||||
dst_width1, dst_height1, dst_stride1);
|
||||
av1_build_prediction_by_left_preds(cm, xd, mi_row, mi_col, dst_buf2,
|
||||
dst_width2, dst_height2, dst_stride2);
|
||||
av1_setup_dst_planes(xd->plane, xd->mi[0]->sb_type, get_frame_new_buffer(cm),
|
||||
mi_row, mi_col, 0, num_planes);
|
||||
av1_build_obmc_inter_prediction(cm, xd, mi_row, mi_col, dst_buf1, dst_stride1,
|
||||
dst_buf2, dst_stride2);
|
||||
}
|
||||
|
||||
// Builds the inter-predictor for the single ref case
|
||||
// for use in the encoder to search the wedges efficiently.
|
||||
static void build_inter_predictors_single_buf(MACROBLOCKD *xd, int plane,
|
||||
int bw, int bh, int x, int y,
|
||||
int w, int h, int mi_x, int mi_y,
|
||||
int ref, uint8_t *const ext_dst,
|
||||
int ext_dst_stride,
|
||||
int can_use_previous) {
|
||||
struct macroblockd_plane *const pd = &xd->plane[plane];
|
||||
const MB_MODE_INFO *mi = xd->mi[0];
|
||||
|
||||
const struct scale_factors *const sf = &xd->block_refs[ref]->sf;
|
||||
struct buf_2d *const pre_buf = &pd->pre[ref];
|
||||
uint8_t *const dst = get_buf_by_bd(xd, ext_dst) + ext_dst_stride * y + x;
|
||||
const MV mv = mi->mv[ref].as_mv;
|
||||
|
||||
ConvolveParams conv_params = get_conv_params(0, plane, xd->bd);
|
||||
WarpTypesAllowed warp_types;
|
||||
const WarpedMotionParams *const wm = &xd->global_motion[mi->ref_frame[ref]];
|
||||
warp_types.global_warp_allowed = is_global_mv_block(mi, wm->wmtype);
|
||||
warp_types.local_warp_allowed = mi->motion_mode == WARPED_CAUSAL;
|
||||
const int pre_x = (mi_x) >> pd->subsampling_x;
|
||||
const int pre_y = (mi_y) >> pd->subsampling_y;
|
||||
uint8_t *pre;
|
||||
SubpelParams subpel_params;
|
||||
calc_subpel_params(xd, sf, mv, plane, pre_x, pre_y, x, y, pre_buf, &pre,
|
||||
&subpel_params, bw, bh);
|
||||
|
||||
av1_make_inter_predictor(pre, pre_buf->stride, dst, ext_dst_stride,
|
||||
&subpel_params, sf, w, h, &conv_params,
|
||||
mi->interp_filters, &warp_types, pre_x + x,
|
||||
pre_y + y, plane, ref, mi, 0, xd, can_use_previous);
|
||||
}
|
||||
|
||||
void av1_build_inter_predictors_for_planes_single_buf(
|
||||
MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane_from, int plane_to, int mi_row,
|
||||
int mi_col, int ref, uint8_t *ext_dst[3], int ext_dst_stride[3],
|
||||
int can_use_previous) {
|
||||
int plane;
|
||||
const int mi_x = mi_col * MI_SIZE;
|
||||
const int mi_y = mi_row * MI_SIZE;
|
||||
for (plane = plane_from; plane <= plane_to; ++plane) {
|
||||
const BLOCK_SIZE plane_bsize = get_plane_block_size(
|
||||
bsize, xd->plane[plane].subsampling_x, xd->plane[plane].subsampling_y);
|
||||
const int bw = block_size_wide[plane_bsize];
|
||||
const int bh = block_size_high[plane_bsize];
|
||||
build_inter_predictors_single_buf(xd, plane, bw, bh, 0, 0, bw, bh, mi_x,
|
||||
mi_y, ref, ext_dst[plane],
|
||||
ext_dst_stride[plane], can_use_previous);
|
||||
}
|
||||
}
|
||||
|
||||
static void build_masked_compound(
|
||||
uint8_t *dst, int dst_stride, const uint8_t *src0, int src0_stride,
|
||||
const uint8_t *src1, int src1_stride,
|
||||
const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE sb_type, int h,
|
||||
int w) {
|
||||
// Derive subsampling from h and w passed in. May be refactored to
|
||||
// pass in subsampling factors directly.
|
||||
const int subh = (2 << mi_size_high_log2[sb_type]) == h;
|
||||
const int subw = (2 << mi_size_wide_log2[sb_type]) == w;
|
||||
const uint8_t *mask = av1_get_compound_type_mask(comp_data, sb_type);
|
||||
aom_blend_a64_mask(dst, dst_stride, src0, src0_stride, src1, src1_stride,
|
||||
mask, block_size_wide[sb_type], w, h, subw, subh);
|
||||
}
|
||||
|
||||
static void build_masked_compound_highbd(
|
||||
uint8_t *dst_8, int dst_stride, const uint8_t *src0_8, int src0_stride,
|
||||
const uint8_t *src1_8, int src1_stride,
|
||||
const INTERINTER_COMPOUND_DATA *const comp_data, BLOCK_SIZE sb_type, int h,
|
||||
int w, int bd) {
|
||||
// Derive subsampling from h and w passed in. May be refactored to
|
||||
// pass in subsampling factors directly.
|
||||
const int subh = (2 << mi_size_high_log2[sb_type]) == h;
|
||||
const int subw = (2 << mi_size_wide_log2[sb_type]) == w;
|
||||
const uint8_t *mask = av1_get_compound_type_mask(comp_data, sb_type);
|
||||
// const uint8_t *mask =
|
||||
// av1_get_contiguous_soft_mask(wedge_index, wedge_sign, sb_type);
|
||||
aom_highbd_blend_a64_mask(dst_8, dst_stride, src0_8, src0_stride, src1_8,
|
||||
src1_stride, mask, block_size_wide[sb_type], w, h,
|
||||
subw, subh, bd);
|
||||
}
|
||||
|
||||
static void build_wedge_inter_predictor_from_buf(
|
||||
MACROBLOCKD *xd, int plane, int x, int y, int w, int h, uint8_t *ext_dst0,
|
||||
int ext_dst_stride0, uint8_t *ext_dst1, int ext_dst_stride1) {
|
||||
MB_MODE_INFO *const mbmi = xd->mi[0];
|
||||
const int is_compound = has_second_ref(mbmi);
|
||||
MACROBLOCKD_PLANE *const pd = &xd->plane[plane];
|
||||
struct buf_2d *const dst_buf = &pd->dst;
|
||||
uint8_t *const dst = dst_buf->buf + dst_buf->stride * y + x;
|
||||
mbmi->interinter_comp.seg_mask = xd->seg_mask;
|
||||
const INTERINTER_COMPOUND_DATA *comp_data = &mbmi->interinter_comp;
|
||||
|
||||
if (is_compound && is_masked_compound_type(comp_data->type)) {
|
||||
if (!plane && comp_data->type == COMPOUND_DIFFWTD) {
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
|
||||
av1_build_compound_diffwtd_mask_highbd(
|
||||
comp_data->seg_mask, comp_data->mask_type,
|
||||
CONVERT_TO_BYTEPTR(ext_dst0), ext_dst_stride0,
|
||||
CONVERT_TO_BYTEPTR(ext_dst1), ext_dst_stride1, h, w, xd->bd);
|
||||
else
|
||||
av1_build_compound_diffwtd_mask(
|
||||
comp_data->seg_mask, comp_data->mask_type, ext_dst0,
|
||||
ext_dst_stride0, ext_dst1, ext_dst_stride1, h, w);
|
||||
}
|
||||
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
|
||||
build_masked_compound_highbd(
|
||||
dst, dst_buf->stride, CONVERT_TO_BYTEPTR(ext_dst0), ext_dst_stride0,
|
||||
CONVERT_TO_BYTEPTR(ext_dst1), ext_dst_stride1, comp_data,
|
||||
mbmi->sb_type, h, w, xd->bd);
|
||||
else
|
||||
build_masked_compound(dst, dst_buf->stride, ext_dst0, ext_dst_stride0,
|
||||
ext_dst1, ext_dst_stride1, comp_data, mbmi->sb_type,
|
||||
h, w);
|
||||
} else {
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH)
|
||||
aom_highbd_convolve_copy(CONVERT_TO_BYTEPTR(ext_dst0), ext_dst_stride0,
|
||||
dst, dst_buf->stride, NULL, 0, NULL, 0, w, h,
|
||||
xd->bd);
|
||||
else
|
||||
aom_convolve_copy(ext_dst0, ext_dst_stride0, dst, dst_buf->stride, NULL,
|
||||
0, NULL, 0, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
void av1_build_wedge_inter_predictor_from_buf(MACROBLOCKD *xd, BLOCK_SIZE bsize,
|
||||
int plane_from, int plane_to,
|
||||
uint8_t *ext_dst0[3],
|
||||
int ext_dst_stride0[3],
|
||||
uint8_t *ext_dst1[3],
|
||||
int ext_dst_stride1[3]) {
|
||||
int plane;
|
||||
for (plane = plane_from; plane <= plane_to; ++plane) {
|
||||
const BLOCK_SIZE plane_bsize = get_plane_block_size(
|
||||
bsize, xd->plane[plane].subsampling_x, xd->plane[plane].subsampling_y);
|
||||
const int bw = block_size_wide[plane_bsize];
|
||||
const int bh = block_size_high[plane_bsize];
|
||||
build_wedge_inter_predictor_from_buf(
|
||||
xd, plane, 0, 0, bw, bh, ext_dst0[plane], ext_dst_stride0[plane],
|
||||
ext_dst1[plane], ext_dst_stride1[plane]);
|
||||
}
|
||||
}
|
||||
127
third_party/aom/av1/encoder/reconinter_enc.h
vendored
Normal file
127
third_party/aom/av1/encoder/reconinter_enc.h
vendored
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
* Copyright (c) 2016, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AOM_AV1_ENCODER_RECONINTER_ENC_H_
|
||||
#define AOM_AV1_ENCODER_RECONINTER_ENC_H_
|
||||
|
||||
#include "aom/aom_integer.h"
|
||||
#include "av1/common/filter.h"
|
||||
#include "av1/common/blockd.h"
|
||||
#include "av1/common/onyxc_int.h"
|
||||
#include "av1/common/convolve.h"
|
||||
#include "av1/common/warped_motion.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void av1_build_inter_predictors_sby(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col, BUFFER_SET *ctx,
|
||||
BLOCK_SIZE bsize);
|
||||
|
||||
void av1_build_inter_predictors_sbuv(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col, BUFFER_SET *ctx,
|
||||
BLOCK_SIZE bsize);
|
||||
|
||||
void av1_build_inter_predictors_sbp(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col, BUFFER_SET *ctx,
|
||||
BLOCK_SIZE bsize, int plane_idx);
|
||||
|
||||
void av1_build_inter_predictors_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col, BUFFER_SET *ctx,
|
||||
BLOCK_SIZE bsize);
|
||||
|
||||
void av1_build_inter_predictor(const uint8_t *src, int src_stride, uint8_t *dst,
|
||||
int dst_stride, const MV *src_mv,
|
||||
const struct scale_factors *sf, int w, int h,
|
||||
ConvolveParams *conv_params,
|
||||
InterpFilters interp_filters,
|
||||
const WarpTypesAllowed *warp_types, int p_col,
|
||||
int p_row, int plane, int ref,
|
||||
enum mv_precision precision, int x, int y,
|
||||
const MACROBLOCKD *xd, int can_use_previous);
|
||||
|
||||
// Detect if the block have sub-pixel level motion vectors
|
||||
// per component.
|
||||
#define CHECK_SUBPEL 0
|
||||
static INLINE int has_subpel_mv_component(const MB_MODE_INFO *const mbmi,
|
||||
const MACROBLOCKD *const xd,
|
||||
int dir) {
|
||||
#if CHECK_SUBPEL
|
||||
const BLOCK_SIZE bsize = mbmi->sb_type;
|
||||
int plane;
|
||||
int ref = (dir >> 1);
|
||||
|
||||
if (dir & 0x01) {
|
||||
if (mbmi->mv[ref].as_mv.col & SUBPEL_MASK) return 1;
|
||||
} else {
|
||||
if (mbmi->mv[ref].as_mv.row & SUBPEL_MASK) return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
#else
|
||||
(void)mbmi;
|
||||
(void)xd;
|
||||
(void)dir;
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
static INLINE int av1_is_interp_search_needed(const MACROBLOCKD *const xd) {
|
||||
MB_MODE_INFO *const mi = xd->mi[0];
|
||||
const int is_compound = has_second_ref(mi);
|
||||
int ref;
|
||||
for (ref = 0; ref < 1 + is_compound; ++ref) {
|
||||
int row_col;
|
||||
for (row_col = 0; row_col < 2; ++row_col) {
|
||||
const int dir = (ref << 1) + row_col;
|
||||
if (has_subpel_mv_component(mi, xd, dir)) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void av1_build_prediction_by_above_preds(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col,
|
||||
uint8_t *tmp_buf[MAX_MB_PLANE],
|
||||
int tmp_width[MAX_MB_PLANE],
|
||||
int tmp_height[MAX_MB_PLANE],
|
||||
int tmp_stride[MAX_MB_PLANE]);
|
||||
|
||||
void av1_build_prediction_by_left_preds(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col,
|
||||
uint8_t *tmp_buf[MAX_MB_PLANE],
|
||||
int tmp_width[MAX_MB_PLANE],
|
||||
int tmp_height[MAX_MB_PLANE],
|
||||
int tmp_stride[MAX_MB_PLANE]);
|
||||
|
||||
void av1_build_obmc_inter_predictors_sb(const AV1_COMMON *cm, MACROBLOCKD *xd,
|
||||
int mi_row, int mi_col);
|
||||
|
||||
void av1_build_inter_predictors_for_planes_single_buf(
|
||||
MACROBLOCKD *xd, BLOCK_SIZE bsize, int plane_from, int plane_to, int mi_row,
|
||||
int mi_col, int ref, uint8_t *ext_dst[3], int ext_dst_stride[3],
|
||||
int can_use_previous);
|
||||
|
||||
void av1_build_wedge_inter_predictor_from_buf(MACROBLOCKD *xd, BLOCK_SIZE bsize,
|
||||
int plane_from, int plane_to,
|
||||
uint8_t *ext_dst0[3],
|
||||
int ext_dst_stride0[3],
|
||||
uint8_t *ext_dst1[3],
|
||||
int ext_dst_stride1[3]);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AOM_AV1_ENCODER_RECONINTER_ENC_H_
|
||||
6
third_party/aom/av1/encoder/segmentation.h
vendored
6
third_party/aom/av1/encoder/segmentation.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_SEGMENTATION_H_
|
||||
#define AV1_ENCODER_SEGMENTATION_H_
|
||||
#ifndef AOM_AV1_ENCODER_SEGMENTATION_H_
|
||||
#define AOM_AV1_ENCODER_SEGMENTATION_H_
|
||||
|
||||
#include "av1/common/blockd.h"
|
||||
#include "av1/encoder/encoder.h"
|
||||
|
|
@ -35,4 +35,4 @@ void av1_reset_segment_features(AV1_COMMON *cm);
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_SEGMENTATION_H_
|
||||
#endif // AOM_AV1_ENCODER_SEGMENTATION_H_
|
||||
|
|
|
|||
145
third_party/aom/av1/encoder/speed_features.c
vendored
145
third_party/aom/av1/encoder/speed_features.c
vendored
|
|
@ -98,6 +98,15 @@ static void set_good_speed_feature_framesize_dependent(AV1_COMP *cpi,
|
|||
sf->use_square_partition_only_threshold = BLOCK_64X64;
|
||||
}
|
||||
|
||||
// TODO(huisu@google.com): train models for 720P and above.
|
||||
if (!is_720p_or_larger) {
|
||||
sf->ml_partition_search_breakout_thresh[0] = 200; // BLOCK_8X8
|
||||
sf->ml_partition_search_breakout_thresh[1] = 250; // BLOCK_16X16
|
||||
sf->ml_partition_search_breakout_thresh[2] = 300; // BLOCK_32X32
|
||||
sf->ml_partition_search_breakout_thresh[3] = 500; // BLOCK_64X64
|
||||
sf->ml_partition_search_breakout_thresh[4] = -1; // BLOCK_128X128
|
||||
}
|
||||
|
||||
if (speed >= 1) {
|
||||
if (is_720p_or_larger) {
|
||||
sf->use_square_partition_only_threshold = BLOCK_128X128;
|
||||
|
|
@ -106,6 +115,14 @@ static void set_good_speed_feature_framesize_dependent(AV1_COMP *cpi,
|
|||
} else {
|
||||
sf->use_square_partition_only_threshold = BLOCK_32X32;
|
||||
}
|
||||
|
||||
if (!is_720p_or_larger) {
|
||||
sf->ml_partition_search_breakout_thresh[0] = 200; // BLOCK_8X8
|
||||
sf->ml_partition_search_breakout_thresh[1] = 250; // BLOCK_16X16
|
||||
sf->ml_partition_search_breakout_thresh[2] = 300; // BLOCK_32X32
|
||||
sf->ml_partition_search_breakout_thresh[3] = 300; // BLOCK_64X64
|
||||
sf->ml_partition_search_breakout_thresh[4] = -1; // BLOCK_128X128
|
||||
}
|
||||
}
|
||||
|
||||
if (speed >= 2) {
|
||||
|
|
@ -126,13 +143,11 @@ static void set_good_speed_feature_framesize_dependent(AV1_COMP *cpi,
|
|||
if (speed >= 3) {
|
||||
if (is_720p_or_larger) {
|
||||
sf->disable_split_mask = DISABLE_ALL_SPLIT;
|
||||
sf->schedule_mode_search = cm->base_qindex < 220 ? 1 : 0;
|
||||
sf->partition_search_breakout_dist_thr = (1 << 25);
|
||||
sf->partition_search_breakout_rate_thr = 200;
|
||||
} else {
|
||||
sf->max_intra_bsize = BLOCK_32X32;
|
||||
sf->disable_split_mask = DISABLE_ALL_INTER_SPLIT;
|
||||
sf->schedule_mode_search = cm->base_qindex < 175 ? 1 : 0;
|
||||
sf->partition_search_breakout_dist_thr = (1 << 23);
|
||||
sf->partition_search_breakout_rate_thr = 120;
|
||||
}
|
||||
|
|
@ -166,6 +181,7 @@ static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
|
|||
// Speed 0 for all speed features that give neutral coding performance change.
|
||||
sf->reduce_inter_modes = 1;
|
||||
sf->prune_ext_partition_types_search_level = 1;
|
||||
sf->ml_prune_rect_partition = 1;
|
||||
sf->ml_prune_ab_partition = 1;
|
||||
sf->ml_prune_4_partition = 1;
|
||||
sf->adaptive_txb_search_level = 1;
|
||||
|
|
@ -173,6 +189,11 @@ static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
|
|||
sf->model_based_prune_tx_search_level = 1;
|
||||
sf->model_based_post_interp_filter_breakout = 1;
|
||||
sf->inter_mode_rd_model_estimation = 1;
|
||||
sf->prune_ref_frame_for_rect_partitions =
|
||||
!(boosted || cpi->refresh_bwd_ref_frame || cpi->refresh_alt2_ref_frame);
|
||||
sf->less_rectangular_check_level = 1;
|
||||
sf->gm_search_type = GM_REDUCED_REF_SEARCH;
|
||||
sf->gm_disable_recode = 1;
|
||||
|
||||
if (speed >= 1) {
|
||||
sf->gm_erroradv_type = GM_ERRORADV_TR_1;
|
||||
|
|
@ -182,8 +203,10 @@ static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
|
|||
sf->intra_tx_size_search_init_depth_rect = 1;
|
||||
sf->intra_tx_size_search_init_depth_sqr = 1;
|
||||
sf->tx_size_search_lgr_block = 1;
|
||||
sf->two_pass_partition_search = 1;
|
||||
sf->mode_pruning_based_on_two_pass_partition_search = 1;
|
||||
if (speed >= CONFIG_2PASS_PARTITION_SEARCH_LVL) {
|
||||
sf->two_pass_partition_search = 1;
|
||||
sf->mode_pruning_based_on_two_pass_partition_search = 1;
|
||||
}
|
||||
sf->prune_ext_partition_types_search_level = 2;
|
||||
sf->use_fast_interpolation_filter_search = 1;
|
||||
sf->skip_repeat_interpolation_filter_search = 1;
|
||||
|
|
@ -198,6 +221,11 @@ static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
|
|||
sf->use_intra_txb_hash = 1;
|
||||
sf->optimize_b_precheck = 1;
|
||||
sf->dual_sgr_penalty_level = 1;
|
||||
sf->use_accurate_subpel_search = 1;
|
||||
sf->reuse_inter_intra_mode = 1;
|
||||
sf->prune_comp_search_by_single_result = 1;
|
||||
sf->skip_repeated_newmv = 1;
|
||||
sf->obmc_full_pixel_search_level = 1;
|
||||
}
|
||||
|
||||
if (speed >= 2) {
|
||||
|
|
@ -206,7 +234,6 @@ static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
|
|||
sf->selective_ref_frame = 2;
|
||||
sf->fast_cdef_search = 1;
|
||||
|
||||
sf->use_rd_breakout = 1;
|
||||
sf->adaptive_rd_thresh = 1;
|
||||
sf->mv.auto_mv_step_size = 1;
|
||||
sf->mv.subpel_iters_per_step = 1;
|
||||
|
|
@ -224,8 +251,7 @@ static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
|
|||
|
||||
if (speed >= 3) {
|
||||
sf->tx_size_search_method = boosted ? USE_FULL_RD : USE_LARGESTALL;
|
||||
sf->less_rectangular_check = 1;
|
||||
sf->mode_skip_start = 10;
|
||||
sf->less_rectangular_check_level = 2;
|
||||
sf->adaptive_pred_interp_filter = 1;
|
||||
// adaptive_motion_search breaks encoder multi-thread tests.
|
||||
// The values in x->pred_mv[] differ for single and multi-thread cases.
|
||||
|
|
@ -237,6 +263,7 @@ static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
|
|||
sf->adaptive_rd_thresh = 2;
|
||||
sf->tx_type_search.prune_mode = PRUNE_2D_FAST;
|
||||
sf->gm_search_type = GM_DISABLE_SEARCH;
|
||||
sf->prune_comp_search_by_single_result = 2;
|
||||
}
|
||||
|
||||
if (speed >= 4) {
|
||||
|
|
@ -250,10 +277,7 @@ static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
|
|||
sf->adaptive_pred_interp_filter = 0;
|
||||
sf->adaptive_mode_search = 1;
|
||||
sf->cb_partition_search = !boosted;
|
||||
sf->cb_pred_filter_search = 1;
|
||||
sf->alt_ref_search_fp = 1;
|
||||
sf->mode_skip_start = 6;
|
||||
sf->adaptive_interp_filter_search = 1;
|
||||
}
|
||||
|
||||
if (speed >= 5) {
|
||||
|
|
@ -276,7 +300,6 @@ static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
|
|||
FLAG_SKIP_COMP_BESTINTRA | FLAG_SKIP_INTRA_LOWVAR |
|
||||
FLAG_EARLY_TERMINATE;
|
||||
sf->disable_filter_search_var_thresh = 200;
|
||||
sf->use_fast_coef_updates = ONE_LOOP_REDUCED;
|
||||
sf->use_fast_coef_costing = 1;
|
||||
sf->partition_search_breakout_rate_thr = 300;
|
||||
sf->use_transform_domain_distortion = 2;
|
||||
|
|
@ -296,33 +319,17 @@ static void set_good_speed_features_framesize_independent(AV1_COMP *cpi,
|
|||
sf->simple_model_rd_from_var = 1;
|
||||
}
|
||||
if (speed >= 7) {
|
||||
const int is_keyframe = cm->frame_type == KEY_FRAME;
|
||||
const int frames_since_key = is_keyframe ? 0 : cpi->rc.frames_since_key;
|
||||
sf->default_max_partition_size = BLOCK_32X32;
|
||||
sf->default_min_partition_size = BLOCK_8X8;
|
||||
sf->intra_y_mode_mask[TX_64X64] = INTRA_DC;
|
||||
sf->intra_y_mode_mask[TX_32X32] = INTRA_DC;
|
||||
sf->frame_parameter_update = 0;
|
||||
sf->mv.search_method = FAST_HEX;
|
||||
sf->inter_mode_mask[BLOCK_32X32] = INTER_NEAREST_NEAR_NEW;
|
||||
sf->inter_mode_mask[BLOCK_32X64] = INTER_NEAREST;
|
||||
sf->inter_mode_mask[BLOCK_64X32] = INTER_NEAREST;
|
||||
sf->inter_mode_mask[BLOCK_64X64] = INTER_NEAREST;
|
||||
sf->inter_mode_mask[BLOCK_64X128] = INTER_NEAREST;
|
||||
sf->inter_mode_mask[BLOCK_128X64] = INTER_NEAREST;
|
||||
sf->inter_mode_mask[BLOCK_128X128] = INTER_NEAREST;
|
||||
sf->partition_search_type = REFERENCE_PARTITION;
|
||||
sf->reuse_inter_pred_sby = 1;
|
||||
sf->force_frame_boost =
|
||||
is_keyframe ||
|
||||
(frames_since_key % (sf->last_partitioning_redo_frequency << 1) == 1);
|
||||
sf->max_delta_qindex = is_keyframe ? 20 : 15;
|
||||
sf->coeff_prob_appx_step = 4;
|
||||
sf->mode_search_skip_flags |= FLAG_SKIP_INTRA_DIRMISMATCH;
|
||||
}
|
||||
if (speed >= 8) {
|
||||
sf->mv.search_method = FAST_DIAMOND;
|
||||
sf->mv.fullpel_search_step_param = 10;
|
||||
sf->mv.subpel_force_stop = 2;
|
||||
sf->lpf_pick = LPF_PICK_MINIMAL_LPF;
|
||||
}
|
||||
|
|
@ -356,54 +363,6 @@ void av1_set_speed_features_framesize_dependent(AV1_COMP *cpi) {
|
|||
cpi->find_fractional_mv_step = av1_return_min_sub_pixel_mv;
|
||||
}
|
||||
|
||||
static void set_dev_sf(AV1_COMP *cpi, SPEED_FEATURES *sf, int speed) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
|
||||
if (speed & TXFM_CODING_SF) {
|
||||
sf->inter_tx_size_search_init_depth_rect = 1;
|
||||
sf->inter_tx_size_search_init_depth_sqr = 1;
|
||||
sf->intra_tx_size_search_init_depth_rect = 1;
|
||||
sf->intra_tx_size_search_init_depth_sqr = 1;
|
||||
sf->tx_size_search_method = USE_FAST_RD;
|
||||
sf->tx_type_search.fast_intra_tx_type_search = 1;
|
||||
sf->tx_type_search.fast_inter_tx_type_search = 1;
|
||||
}
|
||||
|
||||
if (speed & INTER_PRED_SF) {
|
||||
sf->selective_ref_frame = 2;
|
||||
// sf->adaptive_motion_search = 1;
|
||||
sf->mv.auto_mv_step_size = 1;
|
||||
sf->adaptive_rd_thresh = 1;
|
||||
sf->mv.subpel_iters_per_step = 1;
|
||||
sf->adaptive_pred_interp_filter = 1;
|
||||
}
|
||||
|
||||
if (speed & INTRA_PRED_SF) {
|
||||
sf->max_intra_bsize = BLOCK_32X32;
|
||||
}
|
||||
|
||||
if (speed & PARTITION_SF) {
|
||||
if ((cpi->twopass.fr_content_type == FC_GRAPHICS_ANIMATION) ||
|
||||
has_internal_image_edge(cpi)) {
|
||||
sf->use_square_partition_only_threshold =
|
||||
frame_is_boosted(cpi) ? BLOCK_128X128 : BLOCK_4X4;
|
||||
} else {
|
||||
sf->use_square_partition_only_threshold =
|
||||
frame_is_intra_only(cm) ? BLOCK_128X128 : BLOCK_4X4;
|
||||
}
|
||||
sf->less_rectangular_check = 1;
|
||||
sf->prune_ext_partition_types_search_level = 2;
|
||||
}
|
||||
|
||||
if (speed & LOOP_FILTER_SF) {
|
||||
sf->fast_cdef_search = 1;
|
||||
}
|
||||
|
||||
if (speed & RD_SKIP_SF) {
|
||||
sf->use_rd_breakout = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) {
|
||||
AV1_COMMON *const cm = &cpi->common;
|
||||
SPEED_FEATURES *const sf = &cpi->sf;
|
||||
|
|
@ -432,9 +391,7 @@ void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) {
|
|||
#endif // DISABLE_TRELLISQ_SEARCH
|
||||
sf->gm_erroradv_type = GM_ERRORADV_TR_0;
|
||||
sf->mv.reduce_first_step_size = 0;
|
||||
sf->coeff_prob_appx_step = 1;
|
||||
sf->mv.auto_mv_step_size = 0;
|
||||
sf->mv.fullpel_search_step_param = 6;
|
||||
sf->comp_inter_joint_search_thresh = BLOCK_4X4;
|
||||
sf->adaptive_rd_thresh = 0;
|
||||
sf->tx_size_search_method = USE_FULL_RD;
|
||||
|
|
@ -450,7 +407,6 @@ void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) {
|
|||
sf->adaptive_motion_search = 0;
|
||||
sf->adaptive_pred_interp_filter = 0;
|
||||
sf->adaptive_mode_search = 0;
|
||||
sf->cb_pred_filter_search = 0;
|
||||
sf->cb_partition_search = 0;
|
||||
sf->alt_ref_search_fp = 0;
|
||||
sf->partition_search_type = SEARCH_PARTITION;
|
||||
|
|
@ -461,22 +417,19 @@ void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) {
|
|||
sf->tx_type_search.fast_inter_tx_type_search = 0;
|
||||
sf->tx_type_search.skip_tx_search = 0;
|
||||
sf->selective_ref_frame = 0;
|
||||
sf->less_rectangular_check = 0;
|
||||
sf->less_rectangular_check_level = 0;
|
||||
sf->use_square_partition_only_threshold = BLOCK_128X128;
|
||||
sf->prune_ref_frame_for_rect_partitions = 0;
|
||||
sf->auto_min_max_partition_size = NOT_IN_USE;
|
||||
sf->rd_auto_partition_min_limit = BLOCK_4X4;
|
||||
sf->default_max_partition_size = BLOCK_LARGEST;
|
||||
sf->default_min_partition_size = BLOCK_4X4;
|
||||
sf->adjust_partitioning_from_last_frame = 0;
|
||||
sf->last_partitioning_redo_frequency = 4;
|
||||
sf->disable_split_mask = 0;
|
||||
sf->mode_search_skip_flags = 0;
|
||||
sf->force_frame_boost = 0;
|
||||
sf->max_delta_qindex = 0;
|
||||
sf->disable_filter_search_var_thresh = 0;
|
||||
sf->adaptive_interp_filter_search = 0;
|
||||
sf->allow_partition_search_skip = 0;
|
||||
sf->use_accurate_subpel_search = 1;
|
||||
sf->use_accurate_subpel_search = 2;
|
||||
sf->disable_wedge_search_var_thresh = 0;
|
||||
sf->fast_wedge_sign_estimate = 0;
|
||||
sf->drop_ref = 0;
|
||||
|
|
@ -491,48 +444,46 @@ void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) {
|
|||
sf->optimize_b_precheck = 0;
|
||||
sf->jnt_comp_fast_tx_search = 0;
|
||||
sf->jnt_comp_skip_mv_search = 0;
|
||||
sf->reuse_inter_intra_mode = 0;
|
||||
|
||||
for (i = 0; i < TX_SIZES; i++) {
|
||||
sf->intra_y_mode_mask[i] = INTRA_ALL;
|
||||
sf->intra_uv_mode_mask[i] = UV_INTRA_ALL;
|
||||
}
|
||||
sf->use_rd_breakout = 0;
|
||||
sf->lpf_pick = LPF_PICK_FROM_FULL_IMAGE;
|
||||
sf->use_fast_coef_updates = TWO_LOOP;
|
||||
sf->use_fast_coef_costing = 0;
|
||||
sf->mode_skip_start = MAX_MODES; // Mode index at which mode skip mask set
|
||||
sf->schedule_mode_search = 0;
|
||||
for (i = 0; i < BLOCK_SIZES_ALL; ++i) sf->inter_mode_mask[i] = INTER_ALL;
|
||||
sf->max_intra_bsize = BLOCK_LARGEST;
|
||||
sf->reuse_inter_pred_sby = 0;
|
||||
// This setting only takes effect when partition_search_type is set
|
||||
// to FIXED_PARTITION.
|
||||
sf->always_this_block_size = BLOCK_16X16;
|
||||
sf->search_type_check_frequency = 50;
|
||||
// Recode loop tolerance %.
|
||||
sf->recode_tolerance = 25;
|
||||
sf->default_interp_filter = SWITCHABLE;
|
||||
sf->partition_search_breakout_dist_thr = 0;
|
||||
sf->partition_search_breakout_rate_thr = 0;
|
||||
sf->simple_model_rd_from_var = 0;
|
||||
sf->prune_ext_partition_types_search_level = 0;
|
||||
sf->ml_prune_rect_partition = 0;
|
||||
sf->ml_prune_ab_partition = 0;
|
||||
sf->ml_prune_4_partition = 0;
|
||||
sf->fast_cdef_search = 0;
|
||||
for (i = 0; i < PARTITION_BLOCK_SIZES; ++i)
|
||||
sf->ml_partition_search_breakout_thresh[i] = -1; // -1 means not enabled.
|
||||
|
||||
// Set this at the appropriate speed levels
|
||||
sf->use_transform_domain_distortion = 0;
|
||||
sf->gm_search_type = GM_FULL_SEARCH;
|
||||
sf->gm_disable_recode = 0;
|
||||
sf->use_fast_interpolation_filter_search = 0;
|
||||
sf->skip_repeat_interpolation_filter_search = 0;
|
||||
sf->use_hash_based_trellis = 0;
|
||||
sf->prune_comp_search_by_single_result = 0;
|
||||
sf->skip_repeated_newmv = 0;
|
||||
|
||||
// Set decoder side speed feature to use less dual sgr modes
|
||||
sf->dual_sgr_penalty_level = 0;
|
||||
|
||||
sf->inter_mode_rd_model_estimation = 0;
|
||||
|
||||
set_dev_sf(cpi, sf, oxcf->dev_sf);
|
||||
sf->obmc_full_pixel_search_level = 0;
|
||||
|
||||
if (oxcf->mode == GOOD)
|
||||
set_good_speed_features_framesize_independent(cpi, sf, oxcf->speed);
|
||||
|
|
@ -599,10 +550,6 @@ void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) {
|
|||
x->min_partition_size = sf->default_min_partition_size;
|
||||
x->max_partition_size = sf->default_max_partition_size;
|
||||
|
||||
if (!cpi->oxcf.frame_periodic_boost) {
|
||||
sf->max_delta_qindex = 0;
|
||||
}
|
||||
|
||||
// This is only used in motion vector unit test.
|
||||
if (cpi->oxcf.motion_vector_unit_test == 1)
|
||||
cpi->find_fractional_mv_step = av1_return_max_sub_pixel_mv;
|
||||
|
|
@ -611,5 +558,7 @@ void av1_set_speed_features_framesize_independent(AV1_COMP *cpi) {
|
|||
|
||||
#if CONFIG_DIST_8X8
|
||||
if (sf->use_transform_domain_distortion > 0) cpi->oxcf.using_dist_8x8 = 0;
|
||||
|
||||
if (cpi->oxcf.using_dist_8x8) x->min_partition_size = BLOCK_8X8;
|
||||
#endif // CONFIG_DIST_8X8
|
||||
}
|
||||
|
|
|
|||
144
third_party/aom/av1/encoder/speed_features.h
vendored
144
third_party/aom/av1/encoder/speed_features.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_SPEED_FEATURES_H_
|
||||
#define AV1_ENCODER_SPEED_FEATURES_H_
|
||||
#ifndef AOM_AV1_ENCODER_SPEED_FEATURES_H_
|
||||
#define AOM_AV1_ENCODER_SPEED_FEATURES_H_
|
||||
|
||||
#include "av1/common/enums.h"
|
||||
|
||||
|
|
@ -54,25 +54,6 @@ enum {
|
|||
(1 << NEWMV) | (1 << NEAREST_NEARESTMV) | (1 << NEAR_NEARMV) |
|
||||
(1 << NEW_NEWMV) | (1 << NEAREST_NEWMV) | (1 << NEAR_NEWMV) |
|
||||
(1 << NEW_NEARMV) | (1 << NEW_NEARESTMV) | (1 << GLOBAL_GLOBALMV),
|
||||
INTER_NEAREST = (1 << NEARESTMV) | (1 << NEAREST_NEARESTMV) |
|
||||
(1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV),
|
||||
INTER_NEAREST_NEW = (1 << NEARESTMV) | (1 << NEWMV) |
|
||||
(1 << NEAREST_NEARESTMV) | (1 << NEW_NEWMV) |
|
||||
(1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) |
|
||||
(1 << NEW_NEARMV) | (1 << NEAR_NEWMV),
|
||||
INTER_NEAREST_ZERO = (1 << NEARESTMV) | (1 << GLOBALMV) |
|
||||
(1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) |
|
||||
(1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV),
|
||||
INTER_NEAREST_NEW_ZERO = (1 << NEARESTMV) | (1 << GLOBALMV) | (1 << NEWMV) |
|
||||
(1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) |
|
||||
(1 << NEW_NEWMV) | (1 << NEW_NEARESTMV) |
|
||||
(1 << NEAREST_NEWMV) | (1 << NEW_NEARMV) |
|
||||
(1 << NEAR_NEWMV),
|
||||
INTER_NEAREST_NEAR_NEW = (1 << NEARESTMV) | (1 << NEARMV) | (1 << NEWMV) |
|
||||
(1 << NEAREST_NEARESTMV) | (1 << NEW_NEWMV) |
|
||||
(1 << NEW_NEARESTMV) | (1 << NEAREST_NEWMV) |
|
||||
(1 << NEW_NEARMV) | (1 << NEAR_NEWMV) |
|
||||
(1 << NEAR_NEARMV),
|
||||
INTER_NEAREST_NEAR_ZERO = (1 << NEARESTMV) | (1 << NEARMV) | (1 << GLOBALMV) |
|
||||
(1 << NEAREST_NEARESTMV) | (1 << GLOBAL_GLOBALMV) |
|
||||
(1 << NEAREST_NEWMV) | (1 << NEW_NEARESTMV) |
|
||||
|
|
@ -132,11 +113,6 @@ typedef enum {
|
|||
// Other methods to come
|
||||
} SUBPEL_SEARCH_METHODS;
|
||||
|
||||
typedef enum {
|
||||
NO_MOTION_THRESHOLD = 0,
|
||||
LOW_MOTION_THRESHOLD = 7
|
||||
} MOTION_THRESHOLD;
|
||||
|
||||
typedef enum {
|
||||
USE_FULL_RD = 0,
|
||||
USE_FAST_RD,
|
||||
|
|
@ -178,12 +154,6 @@ typedef enum {
|
|||
FLAG_SKIP_INTRA_LOWVAR = 1 << 5,
|
||||
} MODE_SEARCH_SKIP_LOGIC;
|
||||
|
||||
typedef enum {
|
||||
FLAG_SKIP_EIGHTTAP_REGULAR = 1 << EIGHTTAP_REGULAR,
|
||||
FLAG_SKIP_EIGHTTAP_SMOOTH = 1 << EIGHTTAP_SMOOTH,
|
||||
FLAG_SKIP_MULTITAP_SHARP = 1 << MULTITAP_SHARP,
|
||||
} INTERP_FILTER_MASK;
|
||||
|
||||
typedef enum {
|
||||
NO_PRUNE = 0,
|
||||
// eliminates one tx type in vertical and horizontal direction
|
||||
|
|
@ -224,16 +194,6 @@ typedef enum {
|
|||
REFERENCE_PARTITION
|
||||
} PARTITION_SEARCH_TYPE;
|
||||
|
||||
typedef enum {
|
||||
// Does a dry run to see if any of the contexts need to be updated or not,
|
||||
// before the final run.
|
||||
TWO_LOOP = 0,
|
||||
|
||||
// No dry run, also only half the coef contexts and bands are updated.
|
||||
// The rest are not updated at all.
|
||||
ONE_LOOP_REDUCED = 1
|
||||
} FAST_COEFF_UPDATE;
|
||||
|
||||
typedef struct MV_SPEED_FEATURES {
|
||||
// Motion search method (Diamond, NSTEP, Hex, Big Diamond, Square, etc).
|
||||
SEARCH_METHODS search_method;
|
||||
|
|
@ -257,9 +217,6 @@ typedef struct MV_SPEED_FEATURES {
|
|||
|
||||
// Control when to stop subpel search
|
||||
int subpel_force_stop;
|
||||
|
||||
// This variable sets the step_param used in full pel motion search.
|
||||
int fullpel_search_step_param;
|
||||
} MV_SPEED_FEATURES;
|
||||
|
||||
#define MAX_MESH_STEP 4
|
||||
|
|
@ -332,13 +289,6 @@ typedef struct SPEED_FEATURES {
|
|||
// mode to be evaluated. A high value means we will be faster.
|
||||
int adaptive_rd_thresh;
|
||||
|
||||
// Coefficient probability model approximation step size
|
||||
int coeff_prob_appx_step;
|
||||
|
||||
// The threshold is to determine how slow the motino is, it is used when
|
||||
// use_lastframe_partitioning is set to LAST_FRAME_PARTITION_LOW_MOTION
|
||||
MOTION_THRESHOLD lf_motion_threshold;
|
||||
|
||||
// Determine which method we use to determine transform size. We can choose
|
||||
// between options like full rd, largest for prediction size, largest
|
||||
// for intra and model coefs for the rest.
|
||||
|
|
@ -355,11 +305,6 @@ typedef struct SPEED_FEATURES {
|
|||
// largest transform only, since the largest transform block size is 64x64.
|
||||
int tx_size_search_lgr_block;
|
||||
|
||||
// After looking at the first set of modes (set by index here), skip
|
||||
// checking modes for reference frames that don't match the reference frame
|
||||
// of the best so far.
|
||||
int mode_skip_start;
|
||||
|
||||
PARTITION_SEARCH_TYPE partition_search_type;
|
||||
|
||||
TX_TYPE_SEARCH tx_type_search;
|
||||
|
|
@ -397,6 +342,9 @@ typedef struct SPEED_FEATURES {
|
|||
// aggressiveness of pruning in order.
|
||||
int prune_ext_partition_types_search_level;
|
||||
|
||||
// Use a ML model to prune horz and vert partitions
|
||||
int ml_prune_rect_partition;
|
||||
|
||||
// Use a ML model to prune horz_a, horz_b, vert_a and vert_b partitions.
|
||||
int ml_prune_ab_partition;
|
||||
|
||||
|
|
@ -413,12 +361,16 @@ typedef struct SPEED_FEATURES {
|
|||
int mode_pruning_based_on_two_pass_partition_search;
|
||||
|
||||
// Skip rectangular partition test when partition type none gives better
|
||||
// rd than partition type split.
|
||||
int less_rectangular_check;
|
||||
// rd than partition type split. Can take values 0 - 2, 0 referring to no
|
||||
// skipping, and 1 - 2 increasing aggressiveness of skipping in order.
|
||||
int less_rectangular_check_level;
|
||||
|
||||
// Use square partition only beyond this block size.
|
||||
BLOCK_SIZE use_square_partition_only_threshold;
|
||||
|
||||
// Prune reference frames for rectangular partitions.
|
||||
int prune_ref_frame_for_rect_partitions;
|
||||
|
||||
// Sets min and max partition sizes for this superblock based on the
|
||||
// same superblock in last encoded frame, and the left and above neighbor.
|
||||
AUTO_MIN_MAX_MODE auto_min_max_partition_size;
|
||||
|
|
@ -435,10 +387,6 @@ typedef struct SPEED_FEATURES {
|
|||
// frame's partitioning. Only used if use_lastframe_partitioning is set.
|
||||
int adjust_partitioning_from_last_frame;
|
||||
|
||||
// How frequently we re do the partitioning from scratch. Only used if
|
||||
// use_lastframe_partitioning is set.
|
||||
int last_partitioning_redo_frequency;
|
||||
|
||||
// Disables sub 8x8 blocksizes in different scenarios: Choices are to disable
|
||||
// it always, to allow it for only Last frame and Intra, disable it for all
|
||||
// inter modes or to enable it always.
|
||||
|
|
@ -461,8 +409,6 @@ typedef struct SPEED_FEATURES {
|
|||
// Pattern to be used for any exhaustive mesh searches.
|
||||
MESH_PATTERN mesh_patterns[MAX_MESH_STEP];
|
||||
|
||||
int schedule_mode_search;
|
||||
|
||||
// Allows sub 8x8 modes to use the prediction filter that was determined
|
||||
// best for 8x8 mode. If set to 0 we always re check all the filters for
|
||||
// sizes less than 8x8, 1 means we check all filter modes if no 8x8 filter
|
||||
|
|
@ -472,20 +418,10 @@ typedef struct SPEED_FEATURES {
|
|||
// Adaptive prediction mode search
|
||||
int adaptive_mode_search;
|
||||
|
||||
// Chessboard pattern prediction filter type search
|
||||
int cb_pred_filter_search;
|
||||
|
||||
int cb_partition_search;
|
||||
|
||||
int alt_ref_search_fp;
|
||||
|
||||
// Use finer quantizer in every other few frames that run variable block
|
||||
// partition type search.
|
||||
int force_frame_boost;
|
||||
|
||||
// Maximally allowed base quantization index fluctuation.
|
||||
int max_delta_qindex;
|
||||
|
||||
// Implements various heuristics to skip searching modes
|
||||
// The heuristics selected are based on flags
|
||||
// defined in the MODE_SEARCH_SKIP_HEURISTICS enum
|
||||
|
|
@ -506,22 +442,9 @@ typedef struct SPEED_FEATURES {
|
|||
int intra_y_mode_mask[TX_SIZES];
|
||||
int intra_uv_mode_mask[TX_SIZES];
|
||||
|
||||
// This variable enables an early break out of mode testing if the model for
|
||||
// rd built from the prediction signal indicates a value that's much
|
||||
// higher than the best rd we've seen so far.
|
||||
int use_rd_breakout;
|
||||
|
||||
// This feature controls how the loop filter level is determined.
|
||||
LPF_PICK_METHOD lpf_pick;
|
||||
|
||||
// This feature limits the number of coefficients updates we actually do
|
||||
// by only looking at counts from 1/2 the bands.
|
||||
FAST_COEFF_UPDATE use_fast_coef_updates;
|
||||
|
||||
// A binary mask indicating if NEARESTMV, NEARMV, GLOBALMV, NEWMV
|
||||
// modes are used in order from LSB to MSB for each BLOCK_SIZE.
|
||||
int inter_mode_mask[BLOCK_SIZES_ALL];
|
||||
|
||||
// This feature controls whether we do the expensive context update and
|
||||
// calculation in the rd coefficient costing loop.
|
||||
int use_fast_coef_costing;
|
||||
|
|
@ -535,28 +458,13 @@ typedef struct SPEED_FEATURES {
|
|||
// TODO(aconverse): Fold this into one of the other many mode skips
|
||||
BLOCK_SIZE max_intra_bsize;
|
||||
|
||||
// The frequency that we check if
|
||||
// FIXED_PARTITION search type should be used.
|
||||
int search_type_check_frequency;
|
||||
|
||||
// When partition is pre-set, the inter prediction result from pick_inter_mode
|
||||
// can be reused in final block encoding process. It is enabled only for real-
|
||||
// time mode speed 6.
|
||||
int reuse_inter_pred_sby;
|
||||
|
||||
// default interp filter choice
|
||||
InterpFilter default_interp_filter;
|
||||
|
||||
// adaptive interp_filter search to allow skip of certain filter types.
|
||||
int adaptive_interp_filter_search;
|
||||
|
||||
// mask for skip evaluation of certain interp_filter type.
|
||||
INTERP_FILTER_MASK interp_filter_search_mask;
|
||||
|
||||
// Partition search early breakout thresholds.
|
||||
int64_t partition_search_breakout_dist_thr;
|
||||
int partition_search_breakout_rate_thr;
|
||||
|
||||
// Thresholds for ML based partition search breakout.
|
||||
int ml_partition_search_breakout_thresh[PARTITION_BLOCK_SIZES];
|
||||
|
||||
// Allow skipping partition search for still image frame
|
||||
int allow_partition_search_skip;
|
||||
|
||||
|
|
@ -577,6 +485,9 @@ typedef struct SPEED_FEATURES {
|
|||
|
||||
GM_SEARCH_TYPE gm_search_type;
|
||||
|
||||
// whether to disable the global motion recode loop
|
||||
int gm_disable_recode;
|
||||
|
||||
// Do limited interpolation filter search for dual filters, since best choice
|
||||
// usually includes EIGHTTAP_REGULAR.
|
||||
int use_fast_interpolation_filter_search;
|
||||
|
|
@ -624,6 +535,25 @@ typedef struct SPEED_FEATURES {
|
|||
|
||||
// Dynamically estimate final rd from prediction error and mode cost
|
||||
int inter_mode_rd_model_estimation;
|
||||
|
||||
// Skip some ref frames in compound motion search by single motion search
|
||||
// result. Has three levels for now: 0 referring to no skipping, and 1 - 3
|
||||
// increasing aggressiveness of skipping in order.
|
||||
// Note: The search order might affect the result. It is better to search same
|
||||
// single inter mode as a group.
|
||||
int prune_comp_search_by_single_result;
|
||||
|
||||
// Reuse the inter_intra_mode search result from NEARESTMV mode to other
|
||||
// single ref modes
|
||||
int reuse_inter_intra_mode;
|
||||
|
||||
// Set the full pixel search level of obmc
|
||||
// 0: obmc_full_pixel_diamond
|
||||
// 1: obmc_refining_search_sad (faster)
|
||||
int obmc_full_pixel_search_level;
|
||||
|
||||
// flag to skip NEWMV mode in drl if the motion search result is the same
|
||||
int skip_repeated_newmv;
|
||||
} SPEED_FEATURES;
|
||||
|
||||
struct AV1_COMP;
|
||||
|
|
@ -635,4 +565,4 @@ void av1_set_speed_features_framesize_dependent(struct AV1_COMP *cpi);
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_SPEED_FEATURES_H_
|
||||
#endif // AOM_AV1_ENCODER_SPEED_FEATURES_H_
|
||||
|
|
|
|||
81
third_party/aom/av1/encoder/temporal_filter.c
vendored
81
third_party/aom/av1/encoder/temporal_filter.c
vendored
|
|
@ -25,6 +25,7 @@
|
|||
#include "av1/encoder/mcomp.h"
|
||||
#include "av1/encoder/encoder.h"
|
||||
#include "av1/encoder/ratectrl.h"
|
||||
#include "av1/encoder/reconinter_enc.h"
|
||||
#include "av1/encoder/segmentation.h"
|
||||
#include "av1/encoder/temporal_filter.h"
|
||||
#include "aom_dsp/aom_dsp_common.h"
|
||||
|
|
@ -37,13 +38,12 @@ static void temporal_filter_predictors_mb_c(
|
|||
MACROBLOCKD *xd, uint8_t *y_mb_ptr, uint8_t *u_mb_ptr, uint8_t *v_mb_ptr,
|
||||
int stride, int uv_block_width, int uv_block_height, int mv_row, int mv_col,
|
||||
uint8_t *pred, struct scale_factors *scale, int x, int y,
|
||||
int can_use_previous) {
|
||||
const int which_mv = 0;
|
||||
int can_use_previous, int num_planes) {
|
||||
const MV mv = { mv_row, mv_col };
|
||||
enum mv_precision mv_precision_uv;
|
||||
int uv_stride;
|
||||
// TODO(angiebird): change plane setting accordingly
|
||||
ConvolveParams conv_params = get_conv_params(which_mv, 0, 0, xd->bd);
|
||||
ConvolveParams conv_params = get_conv_params(0, 0, xd->bd);
|
||||
const InterpFilters interp_filters = xd->mi[0]->interp_filters;
|
||||
WarpTypesAllowed warp_types;
|
||||
memset(&warp_types, 0, sizeof(WarpTypesAllowed));
|
||||
|
|
@ -55,37 +55,21 @@ static void temporal_filter_predictors_mb_c(
|
|||
uv_stride = stride;
|
||||
mv_precision_uv = MV_PRECISION_Q3;
|
||||
}
|
||||
|
||||
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||
av1_highbd_build_inter_predictor(y_mb_ptr, stride, &pred[0], 16, &mv, scale,
|
||||
16, 16, which_mv, interp_filters,
|
||||
&warp_types, x, y, 0, MV_PRECISION_Q3, x,
|
||||
y, xd, can_use_previous);
|
||||
|
||||
av1_highbd_build_inter_predictor(
|
||||
u_mb_ptr, uv_stride, &pred[256], uv_block_width, &mv, scale,
|
||||
uv_block_width, uv_block_height, which_mv, interp_filters, &warp_types,
|
||||
x, y, 1, mv_precision_uv, x, y, xd, can_use_previous);
|
||||
|
||||
av1_highbd_build_inter_predictor(
|
||||
v_mb_ptr, uv_stride, &pred[512], uv_block_width, &mv, scale,
|
||||
uv_block_width, uv_block_height, which_mv, interp_filters, &warp_types,
|
||||
x, y, 2, mv_precision_uv, x, y, xd, can_use_previous);
|
||||
return;
|
||||
}
|
||||
av1_build_inter_predictor(y_mb_ptr, stride, &pred[0], 16, &mv, scale, 16, 16,
|
||||
&conv_params, interp_filters, &warp_types, x, y, 0,
|
||||
0, MV_PRECISION_Q3, x, y, xd, can_use_previous);
|
||||
|
||||
av1_build_inter_predictor(u_mb_ptr, uv_stride, &pred[256], uv_block_width,
|
||||
&mv, scale, uv_block_width, uv_block_height,
|
||||
&conv_params, interp_filters, &warp_types, x, y, 1,
|
||||
0, mv_precision_uv, x, y, xd, can_use_previous);
|
||||
if (num_planes > 1) {
|
||||
av1_build_inter_predictor(
|
||||
u_mb_ptr, uv_stride, &pred[256], uv_block_width, &mv, scale,
|
||||
uv_block_width, uv_block_height, &conv_params, interp_filters,
|
||||
&warp_types, x, y, 1, 0, mv_precision_uv, x, y, xd, can_use_previous);
|
||||
|
||||
av1_build_inter_predictor(v_mb_ptr, uv_stride, &pred[512], uv_block_width,
|
||||
&mv, scale, uv_block_width, uv_block_height,
|
||||
&conv_params, interp_filters, &warp_types, x, y, 2,
|
||||
0, mv_precision_uv, x, y, xd, can_use_previous);
|
||||
av1_build_inter_predictor(
|
||||
v_mb_ptr, uv_stride, &pred[512], uv_block_width, &mv, scale,
|
||||
uv_block_width, uv_block_height, &conv_params, interp_filters,
|
||||
&warp_types, x, y, 2, 0, mv_precision_uv, x, y, xd, can_use_previous);
|
||||
}
|
||||
}
|
||||
|
||||
void av1_temporal_filter_apply_c(uint8_t *frame1, unsigned int stride,
|
||||
|
|
@ -214,7 +198,8 @@ void av1_highbd_temporal_filter_apply_c(
|
|||
static int temporal_filter_find_matching_mb_c(AV1_COMP *cpi,
|
||||
uint8_t *arf_frame_buf,
|
||||
uint8_t *frame_ptr_buf,
|
||||
int stride) {
|
||||
int stride, int x_pos,
|
||||
int y_pos) {
|
||||
MACROBLOCK *const x = &cpi->td.mb;
|
||||
MACROBLOCKD *const xd = &x->e_mbd;
|
||||
const MV_SPEED_FEATURES *const mv_sf = &cpi->sf.mv;
|
||||
|
|
@ -250,11 +235,9 @@ static int temporal_filter_find_matching_mb_c(AV1_COMP *cpi,
|
|||
x->mvcost = x->mv_cost_stack;
|
||||
x->nmvjointcost = x->nmv_vec_cost;
|
||||
|
||||
// Use mv costing from x->mvcost directly
|
||||
av1_hex_search(x, &best_ref_mv1_full, step_param, sadpb, 1,
|
||||
cond_cost_list(cpi, cost_list), &cpi->fn_ptr[BLOCK_16X16], 0,
|
||||
&best_ref_mv1);
|
||||
|
||||
av1_full_pixel_search(cpi, x, BLOCK_16X16, &best_ref_mv1_full, step_param,
|
||||
NSTEP, 1, sadpb, cond_cost_list(cpi, cost_list),
|
||||
&best_ref_mv1, 0, 0, x_pos, y_pos, 0);
|
||||
x->mv_limits = tmp_mv_limits;
|
||||
|
||||
// Ignore mv costing by sending NULL pointer instead of cost array
|
||||
|
|
@ -370,7 +353,8 @@ static void temporal_filter_iterate_c(AV1_COMP *cpi,
|
|||
// Find best match in this frame by MC
|
||||
int err = temporal_filter_find_matching_mb_c(
|
||||
cpi, frames[alt_ref_index]->y_buffer + mb_y_offset,
|
||||
frames[frame]->y_buffer + mb_y_offset, frames[frame]->y_stride);
|
||||
frames[frame]->y_buffer + mb_y_offset, frames[frame]->y_stride,
|
||||
mb_col * 16, mb_row * 16);
|
||||
|
||||
// Assign higher weight to matching MB if it's error
|
||||
// score is lower. If not applying MC default behavior
|
||||
|
|
@ -386,7 +370,7 @@ static void temporal_filter_iterate_c(AV1_COMP *cpi,
|
|||
frames[frame]->v_buffer + mb_uv_offset, frames[frame]->y_stride,
|
||||
mb_uv_width, mb_uv_height, mbd->mi[0]->mv[0].as_mv.row,
|
||||
mbd->mi[0]->mv[0].as_mv.col, predictor, scale, mb_col * 16,
|
||||
mb_row * 16, cm->allow_warped_motion);
|
||||
mb_row * 16, cm->allow_warped_motion, num_planes);
|
||||
|
||||
// Apply the filter (YUV)
|
||||
if (mbd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
|
||||
|
|
@ -556,14 +540,6 @@ static void adjust_arnr_filter(AV1_COMP *cpi, int distance, int group_boost,
|
|||
strength = group_boost / 300;
|
||||
}
|
||||
|
||||
// Adjustments for second level arf in multi arf case.
|
||||
if (cpi->oxcf.pass == 2 && cpi->multi_arf_allowed) {
|
||||
const GF_GROUP *const gf_group = &cpi->twopass.gf_group;
|
||||
if (gf_group->rf_level[gf_group->index] != GF_ARF_STD) {
|
||||
strength >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
*arnr_frames = frames;
|
||||
*arnr_strength = strength;
|
||||
}
|
||||
|
|
@ -593,21 +569,6 @@ void av1_temporal_filter(AV1_COMP *cpi, int distance) {
|
|||
|
||||
int which_arf = gf_group->arf_update_idx[gf_group->index];
|
||||
|
||||
#if USE_GF16_MULTI_LAYER
|
||||
if (cpi->rc.baseline_gf_interval == 16) {
|
||||
// Identify the index to the current ARF.
|
||||
const int num_arfs_in_gf = cpi->num_extra_arfs + 1;
|
||||
int arf_idx;
|
||||
for (arf_idx = 0; arf_idx < num_arfs_in_gf; arf_idx++) {
|
||||
if (gf_group->index == cpi->arf_pos_in_gf[arf_idx]) {
|
||||
which_arf = arf_idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
assert(arf_idx < num_arfs_in_gf);
|
||||
}
|
||||
#endif // USE_GF16_MULTI_LAYER
|
||||
|
||||
// Set the temporal filtering status for the corresponding OVERLAY frame
|
||||
if (strength == 0 && frames_to_blur == 1)
|
||||
cpi->is_arf_filter_off[which_arf] = 1;
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_TEMPORAL_FILTER_H_
|
||||
#define AV1_ENCODER_TEMPORAL_FILTER_H_
|
||||
#ifndef AOM_AV1_ENCODER_TEMPORAL_FILTER_H_
|
||||
#define AOM_AV1_ENCODER_TEMPORAL_FILTER_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
|
@ -22,4 +22,4 @@ void av1_temporal_filter(AV1_COMP *cpi, int distance);
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_TEMPORAL_FILTER_H_
|
||||
#endif // AOM_AV1_ENCODER_TEMPORAL_FILTER_H_
|
||||
|
|
|
|||
6
third_party/aom/av1/encoder/tokenize.h
vendored
6
third_party/aom/av1/encoder/tokenize.h
vendored
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_ENCODER_TOKENIZE_H_
|
||||
#define AV1_ENCODER_TOKENIZE_H_
|
||||
#ifndef AOM_AV1_ENCODER_TOKENIZE_H_
|
||||
#define AOM_AV1_ENCODER_TOKENIZE_H_
|
||||
|
||||
#include "av1/common/entropy.h"
|
||||
#include "av1/encoder/block.h"
|
||||
|
|
@ -70,4 +70,4 @@ static INLINE int av1_get_tx_eob(const struct segmentation *seg, int segment_id,
|
|||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // AV1_ENCODER_TOKENIZE_H_
|
||||
#endif // AOM_AV1_ENCODER_TOKENIZE_H_
|
||||
|
|
|
|||
1438
third_party/aom/av1/encoder/tx_prune_model_weights.h
vendored
1438
third_party/aom/av1/encoder/tx_prune_model_weights.h
vendored
File diff suppressed because it is too large
Load diff
|
|
@ -395,7 +395,8 @@ void av1_fadst4_new_sse4_1(const __m128i *input, __m128i *output,
|
|||
}
|
||||
|
||||
void av1_fdct64_new_sse4_1(const __m128i *input, __m128i *output,
|
||||
int8_t cos_bit) {
|
||||
int8_t cos_bit, const int instride,
|
||||
const int outstride) {
|
||||
const int32_t *cospi = cospi_arr(cos_bit);
|
||||
const __m128i __rounding = _mm_set1_epi32(1 << (cos_bit - 1));
|
||||
|
||||
|
|
@ -480,70 +481,70 @@ void av1_fdct64_new_sse4_1(const __m128i *input, __m128i *output,
|
|||
|
||||
// stage 1
|
||||
__m128i x1[64];
|
||||
x1[0] = _mm_add_epi32(input[0], input[63]);
|
||||
x1[63] = _mm_sub_epi32(input[0], input[63]);
|
||||
x1[1] = _mm_add_epi32(input[1], input[62]);
|
||||
x1[62] = _mm_sub_epi32(input[1], input[62]);
|
||||
x1[2] = _mm_add_epi32(input[2], input[61]);
|
||||
x1[61] = _mm_sub_epi32(input[2], input[61]);
|
||||
x1[3] = _mm_add_epi32(input[3], input[60]);
|
||||
x1[60] = _mm_sub_epi32(input[3], input[60]);
|
||||
x1[4] = _mm_add_epi32(input[4], input[59]);
|
||||
x1[59] = _mm_sub_epi32(input[4], input[59]);
|
||||
x1[5] = _mm_add_epi32(input[5], input[58]);
|
||||
x1[58] = _mm_sub_epi32(input[5], input[58]);
|
||||
x1[6] = _mm_add_epi32(input[6], input[57]);
|
||||
x1[57] = _mm_sub_epi32(input[6], input[57]);
|
||||
x1[7] = _mm_add_epi32(input[7], input[56]);
|
||||
x1[56] = _mm_sub_epi32(input[7], input[56]);
|
||||
x1[8] = _mm_add_epi32(input[8], input[55]);
|
||||
x1[55] = _mm_sub_epi32(input[8], input[55]);
|
||||
x1[9] = _mm_add_epi32(input[9], input[54]);
|
||||
x1[54] = _mm_sub_epi32(input[9], input[54]);
|
||||
x1[10] = _mm_add_epi32(input[10], input[53]);
|
||||
x1[53] = _mm_sub_epi32(input[10], input[53]);
|
||||
x1[11] = _mm_add_epi32(input[11], input[52]);
|
||||
x1[52] = _mm_sub_epi32(input[11], input[52]);
|
||||
x1[12] = _mm_add_epi32(input[12], input[51]);
|
||||
x1[51] = _mm_sub_epi32(input[12], input[51]);
|
||||
x1[13] = _mm_add_epi32(input[13], input[50]);
|
||||
x1[50] = _mm_sub_epi32(input[13], input[50]);
|
||||
x1[14] = _mm_add_epi32(input[14], input[49]);
|
||||
x1[49] = _mm_sub_epi32(input[14], input[49]);
|
||||
x1[15] = _mm_add_epi32(input[15], input[48]);
|
||||
x1[48] = _mm_sub_epi32(input[15], input[48]);
|
||||
x1[16] = _mm_add_epi32(input[16], input[47]);
|
||||
x1[47] = _mm_sub_epi32(input[16], input[47]);
|
||||
x1[17] = _mm_add_epi32(input[17], input[46]);
|
||||
x1[46] = _mm_sub_epi32(input[17], input[46]);
|
||||
x1[18] = _mm_add_epi32(input[18], input[45]);
|
||||
x1[45] = _mm_sub_epi32(input[18], input[45]);
|
||||
x1[19] = _mm_add_epi32(input[19], input[44]);
|
||||
x1[44] = _mm_sub_epi32(input[19], input[44]);
|
||||
x1[20] = _mm_add_epi32(input[20], input[43]);
|
||||
x1[43] = _mm_sub_epi32(input[20], input[43]);
|
||||
x1[21] = _mm_add_epi32(input[21], input[42]);
|
||||
x1[42] = _mm_sub_epi32(input[21], input[42]);
|
||||
x1[22] = _mm_add_epi32(input[22], input[41]);
|
||||
x1[41] = _mm_sub_epi32(input[22], input[41]);
|
||||
x1[23] = _mm_add_epi32(input[23], input[40]);
|
||||
x1[40] = _mm_sub_epi32(input[23], input[40]);
|
||||
x1[24] = _mm_add_epi32(input[24], input[39]);
|
||||
x1[39] = _mm_sub_epi32(input[24], input[39]);
|
||||
x1[25] = _mm_add_epi32(input[25], input[38]);
|
||||
x1[38] = _mm_sub_epi32(input[25], input[38]);
|
||||
x1[26] = _mm_add_epi32(input[26], input[37]);
|
||||
x1[37] = _mm_sub_epi32(input[26], input[37]);
|
||||
x1[27] = _mm_add_epi32(input[27], input[36]);
|
||||
x1[36] = _mm_sub_epi32(input[27], input[36]);
|
||||
x1[28] = _mm_add_epi32(input[28], input[35]);
|
||||
x1[35] = _mm_sub_epi32(input[28], input[35]);
|
||||
x1[29] = _mm_add_epi32(input[29], input[34]);
|
||||
x1[34] = _mm_sub_epi32(input[29], input[34]);
|
||||
x1[30] = _mm_add_epi32(input[30], input[33]);
|
||||
x1[33] = _mm_sub_epi32(input[30], input[33]);
|
||||
x1[31] = _mm_add_epi32(input[31], input[32]);
|
||||
x1[32] = _mm_sub_epi32(input[31], input[32]);
|
||||
x1[0] = _mm_add_epi32(input[0 * instride], input[63 * instride]);
|
||||
x1[63] = _mm_sub_epi32(input[0 * instride], input[63 * instride]);
|
||||
x1[1] = _mm_add_epi32(input[1 * instride], input[62 * instride]);
|
||||
x1[62] = _mm_sub_epi32(input[1 * instride], input[62 * instride]);
|
||||
x1[2] = _mm_add_epi32(input[2 * instride], input[61 * instride]);
|
||||
x1[61] = _mm_sub_epi32(input[2 * instride], input[61 * instride]);
|
||||
x1[3] = _mm_add_epi32(input[3 * instride], input[60 * instride]);
|
||||
x1[60] = _mm_sub_epi32(input[3 * instride], input[60 * instride]);
|
||||
x1[4] = _mm_add_epi32(input[4 * instride], input[59 * instride]);
|
||||
x1[59] = _mm_sub_epi32(input[4 * instride], input[59 * instride]);
|
||||
x1[5] = _mm_add_epi32(input[5 * instride], input[58 * instride]);
|
||||
x1[58] = _mm_sub_epi32(input[5 * instride], input[58 * instride]);
|
||||
x1[6] = _mm_add_epi32(input[6 * instride], input[57 * instride]);
|
||||
x1[57] = _mm_sub_epi32(input[6 * instride], input[57 * instride]);
|
||||
x1[7] = _mm_add_epi32(input[7 * instride], input[56 * instride]);
|
||||
x1[56] = _mm_sub_epi32(input[7 * instride], input[56 * instride]);
|
||||
x1[8] = _mm_add_epi32(input[8 * instride], input[55 * instride]);
|
||||
x1[55] = _mm_sub_epi32(input[8 * instride], input[55 * instride]);
|
||||
x1[9] = _mm_add_epi32(input[9 * instride], input[54 * instride]);
|
||||
x1[54] = _mm_sub_epi32(input[9 * instride], input[54 * instride]);
|
||||
x1[10] = _mm_add_epi32(input[10 * instride], input[53 * instride]);
|
||||
x1[53] = _mm_sub_epi32(input[10 * instride], input[53 * instride]);
|
||||
x1[11] = _mm_add_epi32(input[11 * instride], input[52 * instride]);
|
||||
x1[52] = _mm_sub_epi32(input[11 * instride], input[52 * instride]);
|
||||
x1[12] = _mm_add_epi32(input[12 * instride], input[51 * instride]);
|
||||
x1[51] = _mm_sub_epi32(input[12 * instride], input[51 * instride]);
|
||||
x1[13] = _mm_add_epi32(input[13 * instride], input[50 * instride]);
|
||||
x1[50] = _mm_sub_epi32(input[13 * instride], input[50 * instride]);
|
||||
x1[14] = _mm_add_epi32(input[14 * instride], input[49 * instride]);
|
||||
x1[49] = _mm_sub_epi32(input[14 * instride], input[49 * instride]);
|
||||
x1[15] = _mm_add_epi32(input[15 * instride], input[48 * instride]);
|
||||
x1[48] = _mm_sub_epi32(input[15 * instride], input[48 * instride]);
|
||||
x1[16] = _mm_add_epi32(input[16 * instride], input[47 * instride]);
|
||||
x1[47] = _mm_sub_epi32(input[16 * instride], input[47 * instride]);
|
||||
x1[17] = _mm_add_epi32(input[17 * instride], input[46 * instride]);
|
||||
x1[46] = _mm_sub_epi32(input[17 * instride], input[46 * instride]);
|
||||
x1[18] = _mm_add_epi32(input[18 * instride], input[45 * instride]);
|
||||
x1[45] = _mm_sub_epi32(input[18 * instride], input[45 * instride]);
|
||||
x1[19] = _mm_add_epi32(input[19 * instride], input[44 * instride]);
|
||||
x1[44] = _mm_sub_epi32(input[19 * instride], input[44 * instride]);
|
||||
x1[20] = _mm_add_epi32(input[20 * instride], input[43 * instride]);
|
||||
x1[43] = _mm_sub_epi32(input[20 * instride], input[43 * instride]);
|
||||
x1[21] = _mm_add_epi32(input[21 * instride], input[42 * instride]);
|
||||
x1[42] = _mm_sub_epi32(input[21 * instride], input[42 * instride]);
|
||||
x1[22] = _mm_add_epi32(input[22 * instride], input[41 * instride]);
|
||||
x1[41] = _mm_sub_epi32(input[22 * instride], input[41 * instride]);
|
||||
x1[23] = _mm_add_epi32(input[23 * instride], input[40 * instride]);
|
||||
x1[40] = _mm_sub_epi32(input[23 * instride], input[40 * instride]);
|
||||
x1[24] = _mm_add_epi32(input[24 * instride], input[39 * instride]);
|
||||
x1[39] = _mm_sub_epi32(input[24 * instride], input[39 * instride]);
|
||||
x1[25] = _mm_add_epi32(input[25 * instride], input[38 * instride]);
|
||||
x1[38] = _mm_sub_epi32(input[25 * instride], input[38 * instride]);
|
||||
x1[26] = _mm_add_epi32(input[26 * instride], input[37 * instride]);
|
||||
x1[37] = _mm_sub_epi32(input[26 * instride], input[37 * instride]);
|
||||
x1[27] = _mm_add_epi32(input[27 * instride], input[36 * instride]);
|
||||
x1[36] = _mm_sub_epi32(input[27 * instride], input[36 * instride]);
|
||||
x1[28] = _mm_add_epi32(input[28 * instride], input[35 * instride]);
|
||||
x1[35] = _mm_sub_epi32(input[28 * instride], input[35 * instride]);
|
||||
x1[29] = _mm_add_epi32(input[29 * instride], input[34 * instride]);
|
||||
x1[34] = _mm_sub_epi32(input[29 * instride], input[34 * instride]);
|
||||
x1[30] = _mm_add_epi32(input[30 * instride], input[33 * instride]);
|
||||
x1[33] = _mm_sub_epi32(input[30 * instride], input[33 * instride]);
|
||||
x1[31] = _mm_add_epi32(input[31 * instride], input[32 * instride]);
|
||||
x1[32] = _mm_sub_epi32(input[31 * instride], input[32 * instride]);
|
||||
|
||||
// stage 2
|
||||
__m128i x2[64];
|
||||
|
|
@ -1149,68 +1150,68 @@ void av1_fdct64_new_sse4_1(const __m128i *input, __m128i *output,
|
|||
x10[48], __rounding, cos_bit);
|
||||
|
||||
// stage 11
|
||||
output[0] = x10[0];
|
||||
output[1] = x10[32];
|
||||
output[2] = x10[16];
|
||||
output[3] = x10[48];
|
||||
output[4] = x10[8];
|
||||
output[5] = x10[40];
|
||||
output[6] = x10[24];
|
||||
output[7] = x10[56];
|
||||
output[8] = x10[4];
|
||||
output[9] = x10[36];
|
||||
output[10] = x10[20];
|
||||
output[11] = x10[52];
|
||||
output[12] = x10[12];
|
||||
output[13] = x10[44];
|
||||
output[14] = x10[28];
|
||||
output[15] = x10[60];
|
||||
output[16] = x10[2];
|
||||
output[17] = x10[34];
|
||||
output[18] = x10[18];
|
||||
output[19] = x10[50];
|
||||
output[20] = x10[10];
|
||||
output[21] = x10[42];
|
||||
output[22] = x10[26];
|
||||
output[23] = x10[58];
|
||||
output[24] = x10[6];
|
||||
output[25] = x10[38];
|
||||
output[26] = x10[22];
|
||||
output[27] = x10[54];
|
||||
output[28] = x10[14];
|
||||
output[29] = x10[46];
|
||||
output[30] = x10[30];
|
||||
output[31] = x10[62];
|
||||
output[32] = x10[1];
|
||||
output[33] = x10[33];
|
||||
output[34] = x10[17];
|
||||
output[35] = x10[49];
|
||||
output[36] = x10[9];
|
||||
output[37] = x10[41];
|
||||
output[38] = x10[25];
|
||||
output[39] = x10[57];
|
||||
output[40] = x10[5];
|
||||
output[41] = x10[37];
|
||||
output[42] = x10[21];
|
||||
output[43] = x10[53];
|
||||
output[44] = x10[13];
|
||||
output[45] = x10[45];
|
||||
output[46] = x10[29];
|
||||
output[47] = x10[61];
|
||||
output[48] = x10[3];
|
||||
output[49] = x10[35];
|
||||
output[50] = x10[19];
|
||||
output[51] = x10[51];
|
||||
output[52] = x10[11];
|
||||
output[53] = x10[43];
|
||||
output[54] = x10[27];
|
||||
output[55] = x10[59];
|
||||
output[56] = x10[7];
|
||||
output[57] = x10[39];
|
||||
output[58] = x10[23];
|
||||
output[59] = x10[55];
|
||||
output[60] = x10[15];
|
||||
output[61] = x10[47];
|
||||
output[62] = x10[31];
|
||||
output[63] = x10[63];
|
||||
output[0 * outstride] = x10[0];
|
||||
output[1 * outstride] = x10[32];
|
||||
output[2 * outstride] = x10[16];
|
||||
output[3 * outstride] = x10[48];
|
||||
output[4 * outstride] = x10[8];
|
||||
output[5 * outstride] = x10[40];
|
||||
output[6 * outstride] = x10[24];
|
||||
output[7 * outstride] = x10[56];
|
||||
output[8 * outstride] = x10[4];
|
||||
output[9 * outstride] = x10[36];
|
||||
output[10 * outstride] = x10[20];
|
||||
output[11 * outstride] = x10[52];
|
||||
output[12 * outstride] = x10[12];
|
||||
output[13 * outstride] = x10[44];
|
||||
output[14 * outstride] = x10[28];
|
||||
output[15 * outstride] = x10[60];
|
||||
output[16 * outstride] = x10[2];
|
||||
output[17 * outstride] = x10[34];
|
||||
output[18 * outstride] = x10[18];
|
||||
output[19 * outstride] = x10[50];
|
||||
output[20 * outstride] = x10[10];
|
||||
output[21 * outstride] = x10[42];
|
||||
output[22 * outstride] = x10[26];
|
||||
output[23 * outstride] = x10[58];
|
||||
output[24 * outstride] = x10[6];
|
||||
output[25 * outstride] = x10[38];
|
||||
output[26 * outstride] = x10[22];
|
||||
output[27 * outstride] = x10[54];
|
||||
output[28 * outstride] = x10[14];
|
||||
output[29 * outstride] = x10[46];
|
||||
output[30 * outstride] = x10[30];
|
||||
output[31 * outstride] = x10[62];
|
||||
output[32 * outstride] = x10[1];
|
||||
output[33 * outstride] = x10[33];
|
||||
output[34 * outstride] = x10[17];
|
||||
output[35 * outstride] = x10[49];
|
||||
output[36 * outstride] = x10[9];
|
||||
output[37 * outstride] = x10[41];
|
||||
output[38 * outstride] = x10[25];
|
||||
output[39 * outstride] = x10[57];
|
||||
output[40 * outstride] = x10[5];
|
||||
output[41 * outstride] = x10[37];
|
||||
output[42 * outstride] = x10[21];
|
||||
output[43 * outstride] = x10[53];
|
||||
output[44 * outstride] = x10[13];
|
||||
output[45 * outstride] = x10[45];
|
||||
output[46 * outstride] = x10[29];
|
||||
output[47 * outstride] = x10[61];
|
||||
output[48 * outstride] = x10[3];
|
||||
output[49 * outstride] = x10[35];
|
||||
output[50 * outstride] = x10[19];
|
||||
output[51 * outstride] = x10[51];
|
||||
output[52 * outstride] = x10[11];
|
||||
output[53 * outstride] = x10[43];
|
||||
output[54 * outstride] = x10[27];
|
||||
output[55 * outstride] = x10[59];
|
||||
output[56 * outstride] = x10[7];
|
||||
output[57 * outstride] = x10[39];
|
||||
output[58 * outstride] = x10[23];
|
||||
output[59 * outstride] = x10[55];
|
||||
output[60 * outstride] = x10[15];
|
||||
output[61 * outstride] = x10[47];
|
||||
output[62 * outstride] = x10[31];
|
||||
output[63 * outstride] = x10[63];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
#include "av1/common/enums.h"
|
||||
#include "av1/common/av1_txfm.h"
|
||||
#include "av1/common/x86/av1_txfm_sse2.h"
|
||||
#include "av1/common/x86/highbd_txfm_utility_sse4.h"
|
||||
#include "av1/encoder/av1_fwd_txfm1d_cfg.h"
|
||||
#include "av1/encoder/x86/av1_txfm1d_sse4.h"
|
||||
#include "av1/encoder/x86/av1_fwd_txfm_sse2.h"
|
||||
|
|
@ -52,9 +53,22 @@ static void fdct32_new_sse4_1(const __m128i *input, __m128i *output,
|
|||
}
|
||||
}
|
||||
|
||||
static void fdct64_new_sse4_1(const __m128i *input, __m128i *output,
|
||||
const int8_t cos_bit, const int8_t *stage_range) {
|
||||
const int txfm_size = 64;
|
||||
const int num_per_128 = 4;
|
||||
int col_num = txfm_size / num_per_128;
|
||||
(void)stage_range;
|
||||
for (int col = 0; col < col_num; col++) {
|
||||
av1_fdct64_new_sse4_1((input + col), (output + col), cos_bit, col_num,
|
||||
col_num);
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE TxfmFuncSSE2 fwd_txfm_type_to_func(TXFM_TYPE txfm_type) {
|
||||
switch (txfm_type) {
|
||||
case TXFM_TYPE_DCT32: return fdct32_new_sse4_1; break;
|
||||
case TXFM_TYPE_DCT64: return fdct64_new_sse4_1; break;
|
||||
default: assert(0);
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -95,6 +109,42 @@ static INLINE void fwd_txfm2d_sse4_1(const int16_t *input, int32_t *output,
|
|||
transpose_32(txfm_size, buf_128, out_128);
|
||||
}
|
||||
|
||||
static INLINE void fwd_txfm2d_64x64_sse4_1(const int16_t *input,
|
||||
int32_t *output, const int stride,
|
||||
const TXFM_2D_FLIP_CFG *cfg,
|
||||
int32_t *txfm_buf) {
|
||||
assert(cfg->tx_size < TX_SIZES);
|
||||
const int txfm_size = tx_size_wide[cfg->tx_size];
|
||||
const int8_t *shift = cfg->shift;
|
||||
const int8_t *stage_range_col = cfg->stage_range_col;
|
||||
const int8_t cos_bit_col = cfg->cos_bit_col;
|
||||
const int8_t cos_bit_row = cfg->cos_bit_row;
|
||||
const TxfmFuncSSE2 txfm_func_col = fwd_txfm_type_to_func(cfg->txfm_type_col);
|
||||
__m128i *buf_128 = (__m128i *)txfm_buf;
|
||||
__m128i *out_128 = (__m128i *)output;
|
||||
|
||||
const int num_per_128 = 4;
|
||||
int txfm2d_size_128 = txfm_size * txfm_size / num_per_128;
|
||||
int col_num = txfm_size / num_per_128;
|
||||
|
||||
int16_array_with_stride_to_int32_array_without_stride(input, stride, output,
|
||||
txfm_size);
|
||||
/*col wise transform*/
|
||||
txfm_func_col(out_128, buf_128, cos_bit_col, stage_range_col);
|
||||
av1_round_shift_array_32_sse4_1(buf_128, out_128, txfm2d_size_128, -shift[1]);
|
||||
transpose_32(txfm_size, out_128, buf_128);
|
||||
|
||||
/*row wise transform*/
|
||||
for (int col = 0; col < (col_num >> 1); col++) {
|
||||
av1_fdct64_new_sse4_1((buf_128 + col), (out_128 + col), cos_bit_row,
|
||||
col_num, (col_num >> 1));
|
||||
}
|
||||
|
||||
txfm2d_size_128 = (col_num >> 1) * (txfm_size >> 1);
|
||||
av1_round_shift_array_32_sse4_1(out_128, buf_128, txfm2d_size_128, -shift[2]);
|
||||
transpose_32x32(buf_128, out_128);
|
||||
}
|
||||
|
||||
void av1_fwd_txfm2d_32x32_sse4_1(const int16_t *input, int32_t *output,
|
||||
int stride, TX_TYPE tx_type, int bd) {
|
||||
DECLARE_ALIGNED(16, int32_t, txfm_buf[1024]);
|
||||
|
|
@ -104,6 +154,15 @@ void av1_fwd_txfm2d_32x32_sse4_1(const int16_t *input, int32_t *output,
|
|||
fwd_txfm2d_sse4_1(input, output, stride, &cfg, txfm_buf);
|
||||
}
|
||||
|
||||
void av1_fwd_txfm2d_64x64_sse4_1(const int16_t *input, int32_t *output,
|
||||
int stride, TX_TYPE tx_type, int bd) {
|
||||
DECLARE_ALIGNED(16, int32_t, txfm_buf[4096]);
|
||||
TXFM_2D_FLIP_CFG cfg;
|
||||
av1_get_fwd_txfm_cfg(tx_type, TX_64X64, &cfg);
|
||||
(void)bd;
|
||||
fwd_txfm2d_64x64_sse4_1(input, output, stride, &cfg, txfm_buf);
|
||||
}
|
||||
|
||||
static INLINE void transpose_32_4x4x2(int stride, const __m128i *inputA,
|
||||
const __m128i *inputB, __m128i *output) {
|
||||
__m128i temp0 = _mm_unpacklo_epi32(inputA[0], inputA[2]);
|
||||
|
|
@ -162,8 +221,8 @@ static void lowbd_fwd_txfm2d_64x64_sse4_1(const int16_t *input, int32_t *output,
|
|||
bufA[j] = _mm_cvtepi16_epi32(buf[j]);
|
||||
bufB[j] = _mm_cvtepi16_epi32(_mm_unpackhi_epi64(buf[j], buf[j]));
|
||||
}
|
||||
av1_fdct64_new_sse4_1(bufA, bufA, cos_bit_row);
|
||||
av1_fdct64_new_sse4_1(bufB, bufB, cos_bit_row);
|
||||
av1_fdct64_new_sse4_1(bufA, bufA, cos_bit_row, 1, 1);
|
||||
av1_fdct64_new_sse4_1(bufB, bufB, cos_bit_row, 1, 1);
|
||||
av1_round_shift_array_32_sse4_1(bufA, bufA, 32, -shift[2]);
|
||||
av1_round_shift_array_32_sse4_1(bufB, bufB, 32, -shift[2]);
|
||||
|
||||
|
|
@ -209,10 +268,10 @@ static void lowbd_fwd_txfm2d_64x32_sse4_1(const int16_t *input, int32_t *output,
|
|||
bufA[j] = _mm_cvtepi16_epi32(buf[j]);
|
||||
bufB[j] = _mm_cvtepi16_epi32(_mm_unpackhi_epi64(buf[j], buf[j]));
|
||||
}
|
||||
av1_fdct64_new_sse4_1(bufA, bufA, cos_bit_row);
|
||||
av1_fdct64_new_sse4_1(bufB, bufB, cos_bit_row);
|
||||
av1_round_shift_rect_array_32_sse4_1(bufA, bufA, 32, -shift[2]);
|
||||
av1_round_shift_rect_array_32_sse4_1(bufB, bufB, 32, -shift[2]);
|
||||
av1_fdct64_new_sse4_1(bufA, bufA, cos_bit_row, 1, 1);
|
||||
av1_fdct64_new_sse4_1(bufB, bufB, cos_bit_row, 1, 1);
|
||||
av1_round_shift_rect_array_32_sse4_1(bufA, bufA, 32, -shift[2], NewSqrt2);
|
||||
av1_round_shift_rect_array_32_sse4_1(bufB, bufB, 32, -shift[2], NewSqrt2);
|
||||
|
||||
int32_t *output8 = output + 8 * 32 * i;
|
||||
for (int j = 0; j < width_div8; ++j) {
|
||||
|
|
@ -260,8 +319,8 @@ static void lowbd_fwd_txfm2d_32x64_sse4_1(const int16_t *input, int32_t *output,
|
|||
}
|
||||
av1_fdct32_new_sse4_1(bufA, bufA, cos_bit_row);
|
||||
av1_fdct32_new_sse4_1(bufB, bufB, cos_bit_row);
|
||||
av1_round_shift_rect_array_32_sse4_1(bufA, bufA, 32, -shift[2]);
|
||||
av1_round_shift_rect_array_32_sse4_1(bufB, bufB, 32, -shift[2]);
|
||||
av1_round_shift_rect_array_32_sse4_1(bufA, bufA, 32, -shift[2], NewSqrt2);
|
||||
av1_round_shift_rect_array_32_sse4_1(bufB, bufB, 32, -shift[2], NewSqrt2);
|
||||
|
||||
int32_t *output8 = output + 8 * 32 * i;
|
||||
for (int j = 0; j < (32 / 4); ++j) {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_FWD_TXFM_AVX2_H_
|
||||
#define AV1_FWD_TXFM_AVX2_H_
|
||||
#ifndef AOM_AV1_ENCODER_X86_AV1_FWD_TXFM_AVX2_H_
|
||||
#define AOM_AV1_ENCODER_X86_AV1_FWD_TXFM_AVX2_H_
|
||||
#include <immintrin.h>
|
||||
|
||||
static INLINE __m256i av1_round_shift_32_avx2(__m256i vec, int bit) {
|
||||
|
|
@ -100,4 +100,4 @@ static INLINE void btf_32_avx2_type1_new(const __m256i ww0, const __m256i ww1,
|
|||
*in1 = _mm256_srai_epi32(temp1, cos_bit);
|
||||
}
|
||||
|
||||
#endif // AV1_FWD_TXFM_AVX2_H_
|
||||
#endif // AOM_AV1_ENCODER_X86_AV1_FWD_TXFM_AVX2_H_
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
#ifndef AV1_COMMON_X86_AV1_FWD_TXFM_SSE2_H_
|
||||
#define AV1_COMMON_X86_AV1_FWD_TXFM_SSE2_H_
|
||||
#ifndef AOM_AV1_ENCODER_X86_AV1_FWD_TXFM_SSE2_H_
|
||||
#define AOM_AV1_ENCODER_X86_AV1_FWD_TXFM_SSE2_H_
|
||||
|
||||
#include <immintrin.h>
|
||||
|
||||
|
|
@ -114,4 +114,4 @@ static const transform_1d_sse2 col_txfm8x32_arr[TX_TYPES] = {
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif // AV1_COMMON_X86_AV1_FWD_TXFM_SSE2_H_
|
||||
#endif // AOM_AV1_ENCODER_X86_AV1_FWD_TXFM_SSE2_H_
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@
|
|||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#ifndef AV1_TXMF1D_SSE2_H_
|
||||
#define AV1_TXMF1D_SSE2_H_
|
||||
#ifndef AOM_AV1_ENCODER_X86_AV1_TXFM1D_SSE4_H_
|
||||
#define AOM_AV1_ENCODER_X86_AV1_TXFM1D_SSE4_H_
|
||||
|
||||
#include <smmintrin.h>
|
||||
#include "av1/common/av1_txfm.h"
|
||||
|
|
@ -29,7 +29,8 @@ void av1_fdct16_new_sse4_1(const __m128i *input, __m128i *output,
|
|||
void av1_fdct32_new_sse4_1(const __m128i *input, __m128i *output,
|
||||
int8_t cos_bit);
|
||||
void av1_fdct64_new_sse4_1(const __m128i *input, __m128i *output,
|
||||
int8_t cos_bit);
|
||||
int8_t cos_bit, const int instride,
|
||||
const int outstride);
|
||||
|
||||
void av1_fadst4_new_sse4_1(const __m128i *input, __m128i *output,
|
||||
const int8_t cos_bit, const int8_t *stage_range);
|
||||
|
|
@ -138,4 +139,4 @@ static INLINE void transpose_32(int txfm_size, const __m128i *input,
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif // AV1_TXMF1D_SSE2_H_
|
||||
#endif // AOM_AV1_ENCODER_X86_AV1_TXFM1D_SSE4_H_
|
||||
|
|
|
|||
130
third_party/aom/av1/encoder/x86/encodetxb_avx2.c
vendored
Normal file
130
third_party/aom/av1/encoder/x86/encodetxb_avx2.c
vendored
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <emmintrin.h> // SSE2
|
||||
#include <smmintrin.h> /* SSE4.1 */
|
||||
#include <immintrin.h> /* AVX2 */
|
||||
|
||||
#include "aom/aom_integer.h"
|
||||
#include "aom_dsp/x86/mem_sse2.h"
|
||||
#include "av1/common/onyxc_int.h"
|
||||
#include "av1/common/txb_common.h"
|
||||
#include "aom_dsp/x86/synonyms.h"
|
||||
#include "aom_dsp/x86/synonyms_avx2.h"
|
||||
|
||||
void av1_txb_init_levels_avx2(const tran_low_t *const coeff, const int width,
|
||||
const int height, uint8_t *const levels) {
|
||||
const int stride = width + TX_PAD_HOR;
|
||||
const __m256i y_zeros = _mm256_setzero_si256();
|
||||
|
||||
const int32_t pre_len = sizeof(*levels) * TX_PAD_TOP * stride;
|
||||
uint8_t *pre_buf = levels - TX_PAD_TOP * stride;
|
||||
uint8_t *pre_buf_end = pre_buf + pre_len;
|
||||
do {
|
||||
yy_storeu_256(pre_buf, y_zeros);
|
||||
pre_buf += 32;
|
||||
} while (pre_buf < pre_buf_end);
|
||||
|
||||
const int32_t bottom_len = sizeof(*levels) * (TX_PAD_BOTTOM * stride);
|
||||
uint8_t *bottom_buf_end = levels + (height + TX_PAD_BOTTOM) * stride;
|
||||
uint8_t *bottom_buf = bottom_buf_end - ((bottom_len + 31) & (~31));
|
||||
|
||||
do {
|
||||
yy_storeu_256(bottom_buf, y_zeros);
|
||||
bottom_buf += 32;
|
||||
} while (bottom_buf < bottom_buf_end);
|
||||
|
||||
int i = 0;
|
||||
uint8_t *ls = levels;
|
||||
const tran_low_t *cf = coeff;
|
||||
if (width == 4) {
|
||||
do {
|
||||
const __m256i c0 = yy_loadu_256(cf);
|
||||
const __m256i c1 = yy_loadu_256(cf + 8);
|
||||
const __m256i abs01 = _mm256_abs_epi16(_mm256_packs_epi32(c0, c1));
|
||||
const __m256i abs01_8 = _mm256_packs_epi16(abs01, y_zeros);
|
||||
const __m256i res_ = _mm256_shuffle_epi32(abs01_8, 0xd8);
|
||||
const __m256i res = _mm256_permute4x64_epi64(res_, 0xd8);
|
||||
yy_storeu_256(ls, res);
|
||||
ls += 32;
|
||||
cf += 16;
|
||||
i += 4;
|
||||
} while (i < height);
|
||||
} else if (width == 8) {
|
||||
do {
|
||||
const __m256i coeffA = yy_loadu_256(cf);
|
||||
const __m256i coeffB = yy_loadu_256(cf + 8);
|
||||
const __m256i coeffC = yy_loadu_256(cf + 16);
|
||||
const __m256i coeffD = yy_loadu_256(cf + 24);
|
||||
const __m256i coeffAB = _mm256_packs_epi32(coeffA, coeffB);
|
||||
const __m256i coeffCD = _mm256_packs_epi32(coeffC, coeffD);
|
||||
const __m256i absAB = _mm256_abs_epi16(coeffAB);
|
||||
const __m256i absCD = _mm256_abs_epi16(coeffCD);
|
||||
const __m256i absABCD = _mm256_packs_epi16(absAB, absCD);
|
||||
const __m256i res_ = _mm256_permute4x64_epi64(absABCD, 0xd8);
|
||||
const __m256i res = _mm256_shuffle_epi32(res_, 0xd8);
|
||||
const __m128i res0 = _mm256_castsi256_si128(res);
|
||||
const __m128i res1 = _mm256_extracti128_si256(res, 1);
|
||||
xx_storel_64(ls, res0);
|
||||
*(int32_t *)(ls + width) = 0;
|
||||
xx_storel_64(ls + stride, _mm_srli_si128(res0, 8));
|
||||
*(int32_t *)(ls + width + stride) = 0;
|
||||
xx_storel_64(ls + stride * 2, res1);
|
||||
*(int32_t *)(ls + width + stride * 2) = 0;
|
||||
xx_storel_64(ls + stride * 3, _mm_srli_si128(res1, 8));
|
||||
*(int32_t *)(ls + width + stride * 3) = 0;
|
||||
cf += 32;
|
||||
ls += stride << 2;
|
||||
i += 4;
|
||||
} while (i < height);
|
||||
} else if (width == 16) {
|
||||
do {
|
||||
const __m256i coeffA = yy_loadu_256(cf);
|
||||
const __m256i coeffB = yy_loadu_256(cf + 8);
|
||||
const __m256i coeffC = yy_loadu_256(cf + 16);
|
||||
const __m256i coeffD = yy_loadu_256(cf + 24);
|
||||
const __m256i coeffAB = _mm256_packs_epi32(coeffA, coeffB);
|
||||
const __m256i coeffCD = _mm256_packs_epi32(coeffC, coeffD);
|
||||
const __m256i absAB = _mm256_abs_epi16(coeffAB);
|
||||
const __m256i absCD = _mm256_abs_epi16(coeffCD);
|
||||
const __m256i absABCD = _mm256_packs_epi16(absAB, absCD);
|
||||
const __m256i res_ = _mm256_permute4x64_epi64(absABCD, 0xd8);
|
||||
const __m256i res = _mm256_shuffle_epi32(res_, 0xd8);
|
||||
xx_storeu_128(ls, _mm256_castsi256_si128(res));
|
||||
xx_storeu_128(ls + stride, _mm256_extracti128_si256(res, 1));
|
||||
cf += 32;
|
||||
*(int32_t *)(ls + width) = 0;
|
||||
*(int32_t *)(ls + stride + width) = 0;
|
||||
ls += stride << 1;
|
||||
i += 2;
|
||||
} while (i < height);
|
||||
} else {
|
||||
do {
|
||||
const __m256i coeffA = yy_loadu_256(cf);
|
||||
const __m256i coeffB = yy_loadu_256(cf + 8);
|
||||
const __m256i coeffC = yy_loadu_256(cf + 16);
|
||||
const __m256i coeffD = yy_loadu_256(cf + 24);
|
||||
const __m256i coeffAB = _mm256_packs_epi32(coeffA, coeffB);
|
||||
const __m256i coeffCD = _mm256_packs_epi32(coeffC, coeffD);
|
||||
const __m256i absAB = _mm256_abs_epi16(coeffAB);
|
||||
const __m256i absCD = _mm256_abs_epi16(coeffCD);
|
||||
const __m256i absABCD = _mm256_packs_epi16(absAB, absCD);
|
||||
const __m256i res_ = _mm256_permute4x64_epi64(absABCD, 0xd8);
|
||||
const __m256i res = _mm256_shuffle_epi32(res_, 0xd8);
|
||||
yy_storeu_256(ls, res);
|
||||
cf += 32;
|
||||
*(int32_t *)(ls + width) = 0;
|
||||
ls += stride;
|
||||
i += 1;
|
||||
} while (i < height);
|
||||
}
|
||||
}
|
||||
46
third_party/aom/av1/encoder/x86/encodetxb_sse4.c
vendored
46
third_party/aom/av1/encoder/x86/encodetxb_sse4.c
vendored
|
|
@ -14,43 +14,55 @@
|
|||
#include <smmintrin.h> /* SSE4.1 */
|
||||
|
||||
#include "aom/aom_integer.h"
|
||||
#include "aom_dsp/x86/mem_sse2.h"
|
||||
#include "av1/common/onyxc_int.h"
|
||||
#include "av1/common/txb_common.h"
|
||||
#include "aom_dsp/x86/synonyms.h"
|
||||
|
||||
void av1_txb_init_levels_sse4_1(const tran_low_t *const coeff, const int width,
|
||||
const int height, uint8_t *const levels) {
|
||||
const int stride = width + TX_PAD_HOR;
|
||||
memset(levels - TX_PAD_TOP * stride, 0,
|
||||
sizeof(*levels) * TX_PAD_TOP * stride);
|
||||
memset(levels + stride * height, 0,
|
||||
sizeof(*levels) * (TX_PAD_BOTTOM * stride + TX_PAD_END));
|
||||
|
||||
const __m128i zeros = _mm_setzero_si128();
|
||||
|
||||
const int32_t pre_len = sizeof(*levels) * TX_PAD_TOP * stride;
|
||||
uint8_t *pre_buf = levels - TX_PAD_TOP * stride;
|
||||
uint8_t *pre_buf_end = pre_buf + pre_len;
|
||||
do {
|
||||
_mm_storeu_si128((__m128i *)(pre_buf), zeros);
|
||||
pre_buf += 16;
|
||||
} while (pre_buf < pre_buf_end);
|
||||
|
||||
const int32_t bottom_len = sizeof(*levels) * (TX_PAD_BOTTOM * stride);
|
||||
uint8_t *bottom_buf = levels + stride * height;
|
||||
uint8_t *bottom_buf_end = bottom_buf + bottom_len;
|
||||
do {
|
||||
_mm_storeu_si128((__m128i *)(bottom_buf), zeros);
|
||||
bottom_buf += 16;
|
||||
} while (bottom_buf < bottom_buf_end);
|
||||
|
||||
int i = 0;
|
||||
uint8_t *ls = levels;
|
||||
const tran_low_t *cf = coeff;
|
||||
if (width == 4) {
|
||||
do {
|
||||
const __m128i coeffA = _mm_load_si128((__m128i *)(cf));
|
||||
const __m128i coeffB = _mm_load_si128((__m128i *)(cf + width));
|
||||
const __m128i coeffA = xx_loadu_128(cf);
|
||||
const __m128i coeffB = xx_loadu_128(cf + 4);
|
||||
const __m128i coeffAB = _mm_packs_epi32(coeffA, coeffB);
|
||||
const __m128i absAB = _mm_abs_epi16(coeffAB);
|
||||
const __m128i absAB8 = _mm_packs_epi16(absAB, zeros);
|
||||
const __m128i lsAB = _mm_unpacklo_epi32(absAB8, zeros);
|
||||
_mm_storeu_si128((__m128i *)ls, lsAB);
|
||||
xx_storeu_128(ls, lsAB);
|
||||
ls += (stride << 1);
|
||||
cf += (width << 1);
|
||||
i += 2;
|
||||
} while (i < height);
|
||||
} else if (width == 8) {
|
||||
do {
|
||||
const __m128i coeffA = _mm_load_si128((__m128i *)(cf));
|
||||
const __m128i coeffB = _mm_load_si128((__m128i *)(cf + 4));
|
||||
const __m128i coeffA = xx_loadu_128(cf);
|
||||
const __m128i coeffB = xx_loadu_128(cf + 4);
|
||||
const __m128i coeffAB = _mm_packs_epi32(coeffA, coeffB);
|
||||
const __m128i absAB = _mm_abs_epi16(coeffAB);
|
||||
const __m128i absAB8 = _mm_packs_epi16(absAB, zeros);
|
||||
_mm_storeu_si128((__m128i *)ls, absAB8);
|
||||
xx_storeu_128(ls, absAB8);
|
||||
ls += stride;
|
||||
cf += width;
|
||||
i += 1;
|
||||
|
|
@ -59,16 +71,16 @@ void av1_txb_init_levels_sse4_1(const tran_low_t *const coeff, const int width,
|
|||
do {
|
||||
int j = 0;
|
||||
do {
|
||||
const __m128i coeffA = _mm_load_si128((__m128i *)(cf));
|
||||
const __m128i coeffB = _mm_load_si128((__m128i *)(cf + 4));
|
||||
const __m128i coeffC = _mm_load_si128((__m128i *)(cf + 8));
|
||||
const __m128i coeffD = _mm_load_si128((__m128i *)(cf + 12));
|
||||
const __m128i coeffA = xx_loadu_128(cf);
|
||||
const __m128i coeffB = xx_loadu_128(cf + 4);
|
||||
const __m128i coeffC = xx_loadu_128(cf + 8);
|
||||
const __m128i coeffD = xx_loadu_128(cf + 12);
|
||||
const __m128i coeffAB = _mm_packs_epi32(coeffA, coeffB);
|
||||
const __m128i coeffCD = _mm_packs_epi32(coeffC, coeffD);
|
||||
const __m128i absAB = _mm_abs_epi16(coeffAB);
|
||||
const __m128i absCD = _mm_abs_epi16(coeffCD);
|
||||
const __m128i absABCD = _mm_packs_epi16(absAB, absCD);
|
||||
_mm_storeu_si128((__m128i *)(ls + j), absABCD);
|
||||
xx_storeu_128(ls + j, absABCD);
|
||||
j += 16;
|
||||
cf += 16;
|
||||
} while (j < width);
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "av1/common/av1_txfm.h"
|
||||
#include "av1/common/x86/highbd_txfm_utility_sse4.h"
|
||||
#include "av1/encoder/av1_fwd_txfm1d_cfg.h"
|
||||
#include "av1/encoder/x86/av1_txfm1d_sse4.h"
|
||||
#include "aom_dsp/txfm_common.h"
|
||||
#include "aom_dsp/x86/txfm_common_sse2.h"
|
||||
#include "aom_ports/mem.h"
|
||||
|
|
@ -393,7 +394,32 @@ static INLINE void write_buffer_8x8(const __m128i *res, int32_t *output) {
|
|||
_mm_store_si128((__m128i *)(output + 15 * 4), res[15]);
|
||||
}
|
||||
|
||||
static void fdct8x8_sse4_1(__m128i *in, __m128i *out, int bit) {
|
||||
static INLINE void write_buffer_16x8(const __m128i *res, int32_t *output,
|
||||
const int stride) {
|
||||
_mm_storeu_si128((__m128i *)(output), res[0]);
|
||||
_mm_storeu_si128((__m128i *)(output + 4), res[1]);
|
||||
_mm_storeu_si128((__m128i *)(output + stride), res[2]);
|
||||
_mm_storeu_si128((__m128i *)(output + stride + 4), res[3]);
|
||||
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 2)), res[4]);
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 2) + 4), res[5]);
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 3)), res[6]);
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 3) + 4), res[7]);
|
||||
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 4)), res[8]);
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 4) + 4), res[9]);
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 5)), res[10]);
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 5) + 4), res[11]);
|
||||
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 6)), res[12]);
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 6) + 4), res[13]);
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 7)), res[14]);
|
||||
_mm_storeu_si128((__m128i *)(output + (stride * 7) + 4), res[15]);
|
||||
}
|
||||
|
||||
static void fdct8x8_sse4_1(__m128i *in, __m128i *out, int bit,
|
||||
const int col_num) {
|
||||
(void)(col_num);
|
||||
const int32_t *cospi = cospi_arr(bit);
|
||||
const __m128i cospi32 = _mm_set1_epi32(cospi[32]);
|
||||
const __m128i cospim32 = _mm_set1_epi32(-cospi[32]);
|
||||
|
|
@ -589,7 +615,9 @@ static void fdct8x8_sse4_1(__m128i *in, __m128i *out, int bit) {
|
|||
out[13] = u[3]; // buf0[3]
|
||||
}
|
||||
|
||||
static void fadst8x8_sse4_1(__m128i *in, __m128i *out, int bit) {
|
||||
static void fadst8x8_sse4_1(__m128i *in, __m128i *out, int bit,
|
||||
const int col_num) {
|
||||
(void)(col_num);
|
||||
const int32_t *cospi = cospi_arr(bit);
|
||||
const __m128i cospi32 = _mm_set1_epi32(cospi[32]);
|
||||
const __m128i cospi16 = _mm_set1_epi32(cospi[16]);
|
||||
|
|
@ -780,82 +808,82 @@ void av1_fwd_txfm2d_8x8_sse4_1(const int16_t *input, int32_t *coeff, int stride,
|
|||
switch (tx_type) {
|
||||
case DCT_DCT:
|
||||
load_buffer_8x8(input, in, stride, 0, 0, shift[0]);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], 0);
|
||||
col_txfm_8x8_rounding(out, -shift[1]);
|
||||
transpose_8x8(out, in);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], 0);
|
||||
transpose_8x8(out, in);
|
||||
write_buffer_8x8(in, coeff);
|
||||
break;
|
||||
case ADST_DCT:
|
||||
load_buffer_8x8(input, in, stride, 0, 0, shift[0]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], 0);
|
||||
col_txfm_8x8_rounding(out, -shift[1]);
|
||||
transpose_8x8(out, in);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], 0);
|
||||
transpose_8x8(out, in);
|
||||
write_buffer_8x8(in, coeff);
|
||||
break;
|
||||
case DCT_ADST:
|
||||
load_buffer_8x8(input, in, stride, 0, 0, shift[0]);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], 0);
|
||||
col_txfm_8x8_rounding(out, -shift[1]);
|
||||
transpose_8x8(out, in);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], 0);
|
||||
transpose_8x8(out, in);
|
||||
write_buffer_8x8(in, coeff);
|
||||
break;
|
||||
case ADST_ADST:
|
||||
load_buffer_8x8(input, in, stride, 0, 0, shift[0]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], 0);
|
||||
col_txfm_8x8_rounding(out, -shift[1]);
|
||||
transpose_8x8(out, in);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], 0);
|
||||
transpose_8x8(out, in);
|
||||
write_buffer_8x8(in, coeff);
|
||||
break;
|
||||
case FLIPADST_DCT:
|
||||
load_buffer_8x8(input, in, stride, 1, 0, shift[0]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], 0);
|
||||
col_txfm_8x8_rounding(out, -shift[1]);
|
||||
transpose_8x8(out, in);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], 0);
|
||||
transpose_8x8(out, in);
|
||||
write_buffer_8x8(in, coeff);
|
||||
break;
|
||||
case DCT_FLIPADST:
|
||||
load_buffer_8x8(input, in, stride, 0, 1, shift[0]);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fdct8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], 0);
|
||||
col_txfm_8x8_rounding(out, -shift[1]);
|
||||
transpose_8x8(out, in);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], 0);
|
||||
transpose_8x8(out, in);
|
||||
write_buffer_8x8(in, coeff);
|
||||
break;
|
||||
case FLIPADST_FLIPADST:
|
||||
load_buffer_8x8(input, in, stride, 1, 1, shift[0]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], 0);
|
||||
col_txfm_8x8_rounding(out, -shift[1]);
|
||||
transpose_8x8(out, in);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], 0);
|
||||
transpose_8x8(out, in);
|
||||
write_buffer_8x8(in, coeff);
|
||||
break;
|
||||
case ADST_FLIPADST:
|
||||
load_buffer_8x8(input, in, stride, 0, 1, shift[0]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], 0);
|
||||
col_txfm_8x8_rounding(out, -shift[1]);
|
||||
transpose_8x8(out, in);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], 0);
|
||||
transpose_8x8(out, in);
|
||||
write_buffer_8x8(in, coeff);
|
||||
break;
|
||||
case FLIPADST_ADST:
|
||||
load_buffer_8x8(input, in, stride, 1, 0, shift[0]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], 0);
|
||||
col_txfm_8x8_rounding(out, -shift[1]);
|
||||
transpose_8x8(out, in);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst8x8_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], 0);
|
||||
transpose_8x8(out, in);
|
||||
write_buffer_8x8(in, coeff);
|
||||
break;
|
||||
|
|
@ -940,7 +968,26 @@ static INLINE void load_buffer_16x16(const int16_t *input, __m128i *out,
|
|||
convert_8x8_to_16x16(in, out);
|
||||
}
|
||||
|
||||
static void fdct16x16_sse4_1(__m128i *in, __m128i *out, int bit) {
|
||||
static INLINE void load_buffer_8x16(const int16_t *input, __m128i *out,
|
||||
int stride, int flipud, int fliplr,
|
||||
int shift) {
|
||||
const int16_t *topL = input;
|
||||
const int16_t *botL = input + 8 * stride;
|
||||
|
||||
const int16_t *tmp;
|
||||
|
||||
if (flipud) {
|
||||
tmp = topL;
|
||||
topL = botL;
|
||||
botL = tmp;
|
||||
}
|
||||
|
||||
load_buffer_8x8(topL, out, stride, flipud, fliplr, shift);
|
||||
load_buffer_8x8(botL, out + 16, stride, flipud, fliplr, shift);
|
||||
}
|
||||
|
||||
static void fdct16x16_sse4_1(__m128i *in, __m128i *out, int bit,
|
||||
const int col_num) {
|
||||
const int32_t *cospi = cospi_arr(bit);
|
||||
const __m128i cospi32 = _mm_set1_epi32(cospi[32]);
|
||||
const __m128i cospim32 = _mm_set1_epi32(-cospi[32]);
|
||||
|
|
@ -962,7 +1009,6 @@ static void fdct16x16_sse4_1(__m128i *in, __m128i *out, int bit) {
|
|||
const __m128i cospi52 = _mm_set1_epi32(cospi[52]);
|
||||
const __m128i rnding = _mm_set1_epi32(1 << (bit - 1));
|
||||
__m128i u[16], v[16], x;
|
||||
const int col_num = 4;
|
||||
int col;
|
||||
|
||||
// Calculate the column 0, 1, 2, 3
|
||||
|
|
@ -1226,7 +1272,8 @@ static void fdct16x16_sse4_1(__m128i *in, __m128i *out, int bit) {
|
|||
}
|
||||
}
|
||||
|
||||
static void fadst16x16_sse4_1(__m128i *in, __m128i *out, int bit) {
|
||||
static void fadst16x16_sse4_1(__m128i *in, __m128i *out, int bit,
|
||||
const int num_cols) {
|
||||
const int32_t *cospi = cospi_arr(bit);
|
||||
const __m128i cospi32 = _mm_set1_epi32(cospi[32]);
|
||||
const __m128i cospi48 = _mm_set1_epi32(cospi[48]);
|
||||
|
|
@ -1271,25 +1318,25 @@ static void fadst16x16_sse4_1(__m128i *in, __m128i *out, int bit) {
|
|||
__m128i u[16], v[16], x, y;
|
||||
int col;
|
||||
|
||||
for (col = 0; col < 4; ++col) {
|
||||
for (col = 0; col < num_cols; ++col) {
|
||||
// stage 0
|
||||
// stage 1
|
||||
u[0] = in[0 * 4 + col];
|
||||
u[1] = _mm_sub_epi32(zero, in[15 * 4 + col]);
|
||||
u[2] = _mm_sub_epi32(zero, in[7 * 4 + col]);
|
||||
u[3] = in[8 * 4 + col];
|
||||
u[4] = _mm_sub_epi32(zero, in[3 * 4 + col]);
|
||||
u[5] = in[12 * 4 + col];
|
||||
u[6] = in[4 * 4 + col];
|
||||
u[7] = _mm_sub_epi32(zero, in[11 * 4 + col]);
|
||||
u[8] = _mm_sub_epi32(zero, in[1 * 4 + col]);
|
||||
u[9] = in[14 * 4 + col];
|
||||
u[10] = in[6 * 4 + col];
|
||||
u[11] = _mm_sub_epi32(zero, in[9 * 4 + col]);
|
||||
u[12] = in[2 * 4 + col];
|
||||
u[13] = _mm_sub_epi32(zero, in[13 * 4 + col]);
|
||||
u[14] = _mm_sub_epi32(zero, in[5 * 4 + col]);
|
||||
u[15] = in[10 * 4 + col];
|
||||
u[0] = in[0 * num_cols + col];
|
||||
u[1] = _mm_sub_epi32(zero, in[15 * num_cols + col]);
|
||||
u[2] = _mm_sub_epi32(zero, in[7 * num_cols + col]);
|
||||
u[3] = in[8 * num_cols + col];
|
||||
u[4] = _mm_sub_epi32(zero, in[3 * num_cols + col]);
|
||||
u[5] = in[12 * num_cols + col];
|
||||
u[6] = in[4 * num_cols + col];
|
||||
u[7] = _mm_sub_epi32(zero, in[11 * num_cols + col]);
|
||||
u[8] = _mm_sub_epi32(zero, in[1 * num_cols + col]);
|
||||
u[9] = in[14 * num_cols + col];
|
||||
u[10] = in[6 * num_cols + col];
|
||||
u[11] = _mm_sub_epi32(zero, in[9 * num_cols + col]);
|
||||
u[12] = in[2 * num_cols + col];
|
||||
u[13] = _mm_sub_epi32(zero, in[13 * num_cols + col]);
|
||||
u[14] = _mm_sub_epi32(zero, in[5 * num_cols + col]);
|
||||
u[15] = in[10 * num_cols + col];
|
||||
|
||||
// stage 2
|
||||
v[0] = u[0];
|
||||
|
|
@ -1453,22 +1500,22 @@ static void fadst16x16_sse4_1(__m128i *in, __m128i *out, int bit) {
|
|||
v[15] = half_btf_sse4_1(&cospi6, &u[14], &cospim58, &u[15], &rnding, bit);
|
||||
|
||||
// stage 9
|
||||
out[0 * 4 + col] = v[1];
|
||||
out[1 * 4 + col] = v[14];
|
||||
out[2 * 4 + col] = v[3];
|
||||
out[3 * 4 + col] = v[12];
|
||||
out[4 * 4 + col] = v[5];
|
||||
out[5 * 4 + col] = v[10];
|
||||
out[6 * 4 + col] = v[7];
|
||||
out[7 * 4 + col] = v[8];
|
||||
out[8 * 4 + col] = v[9];
|
||||
out[9 * 4 + col] = v[6];
|
||||
out[10 * 4 + col] = v[11];
|
||||
out[11 * 4 + col] = v[4];
|
||||
out[12 * 4 + col] = v[13];
|
||||
out[13 * 4 + col] = v[2];
|
||||
out[14 * 4 + col] = v[15];
|
||||
out[15 * 4 + col] = v[0];
|
||||
out[0 * num_cols + col] = v[1];
|
||||
out[1 * num_cols + col] = v[14];
|
||||
out[2 * num_cols + col] = v[3];
|
||||
out[3 * num_cols + col] = v[12];
|
||||
out[4 * num_cols + col] = v[5];
|
||||
out[5 * num_cols + col] = v[10];
|
||||
out[6 * num_cols + col] = v[7];
|
||||
out[7 * num_cols + col] = v[8];
|
||||
out[8 * num_cols + col] = v[9];
|
||||
out[9 * num_cols + col] = v[6];
|
||||
out[10 * num_cols + col] = v[11];
|
||||
out[11 * num_cols + col] = v[4];
|
||||
out[12 * num_cols + col] = v[13];
|
||||
out[13 * num_cols + col] = v[2];
|
||||
out[14 * num_cols + col] = v[15];
|
||||
out[15 * num_cols + col] = v[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1482,6 +1529,11 @@ static void col_txfm_16x16_rounding(__m128i *in, int shift) {
|
|||
col_txfm_8x8_rounding(&in[48], shift);
|
||||
}
|
||||
|
||||
static void col_txfm_8x16_rounding(__m128i *in, int shift) {
|
||||
col_txfm_8x8_rounding(&in[0], shift);
|
||||
col_txfm_8x8_rounding(&in[16], shift);
|
||||
}
|
||||
|
||||
static void write_buffer_16x16(const __m128i *in, int32_t *output) {
|
||||
const int size_8x8 = 16 * 4;
|
||||
write_buffer_8x8(&in[0], output);
|
||||
|
|
@ -1499,85 +1551,86 @@ void av1_fwd_txfm2d_16x16_sse4_1(const int16_t *input, int32_t *coeff,
|
|||
const int8_t *shift = fwd_txfm_shift_ls[TX_16X16];
|
||||
const int txw_idx = get_txw_idx(TX_16X16);
|
||||
const int txh_idx = get_txh_idx(TX_16X16);
|
||||
const int col_num = 4;
|
||||
switch (tx_type) {
|
||||
case DCT_DCT:
|
||||
load_buffer_16x16(input, in, stride, 0, 0, shift[0]);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], col_num);
|
||||
col_txfm_16x16_rounding(out, -shift[1]);
|
||||
transpose_16x16(out, in);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], col_num);
|
||||
transpose_16x16(out, in);
|
||||
write_buffer_16x16(in, coeff);
|
||||
break;
|
||||
case ADST_DCT:
|
||||
load_buffer_16x16(input, in, stride, 0, 0, shift[0]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], col_num);
|
||||
col_txfm_16x16_rounding(out, -shift[1]);
|
||||
transpose_16x16(out, in);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], col_num);
|
||||
transpose_16x16(out, in);
|
||||
write_buffer_16x16(in, coeff);
|
||||
break;
|
||||
case DCT_ADST:
|
||||
load_buffer_16x16(input, in, stride, 0, 0, shift[0]);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], col_num);
|
||||
col_txfm_16x16_rounding(out, -shift[1]);
|
||||
transpose_16x16(out, in);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], col_num);
|
||||
transpose_16x16(out, in);
|
||||
write_buffer_16x16(in, coeff);
|
||||
break;
|
||||
case ADST_ADST:
|
||||
load_buffer_16x16(input, in, stride, 0, 0, shift[0]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], col_num);
|
||||
col_txfm_16x16_rounding(out, -shift[1]);
|
||||
transpose_16x16(out, in);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], col_num);
|
||||
transpose_16x16(out, in);
|
||||
write_buffer_16x16(in, coeff);
|
||||
break;
|
||||
case FLIPADST_DCT:
|
||||
load_buffer_16x16(input, in, stride, 1, 0, shift[0]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], col_num);
|
||||
col_txfm_16x16_rounding(out, -shift[1]);
|
||||
transpose_16x16(out, in);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], col_num);
|
||||
transpose_16x16(out, in);
|
||||
write_buffer_16x16(in, coeff);
|
||||
break;
|
||||
case DCT_FLIPADST:
|
||||
load_buffer_16x16(input, in, stride, 0, 1, shift[0]);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fdct16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], col_num);
|
||||
col_txfm_16x16_rounding(out, -shift[1]);
|
||||
transpose_16x16(out, in);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], col_num);
|
||||
transpose_16x16(out, in);
|
||||
write_buffer_16x16(in, coeff);
|
||||
break;
|
||||
case FLIPADST_FLIPADST:
|
||||
load_buffer_16x16(input, in, stride, 1, 1, shift[0]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], col_num);
|
||||
col_txfm_16x16_rounding(out, -shift[1]);
|
||||
transpose_16x16(out, in);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], col_num);
|
||||
transpose_16x16(out, in);
|
||||
write_buffer_16x16(in, coeff);
|
||||
break;
|
||||
case ADST_FLIPADST:
|
||||
load_buffer_16x16(input, in, stride, 0, 1, shift[0]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], col_num);
|
||||
col_txfm_16x16_rounding(out, -shift[1]);
|
||||
transpose_16x16(out, in);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], col_num);
|
||||
transpose_16x16(out, in);
|
||||
write_buffer_16x16(in, coeff);
|
||||
break;
|
||||
case FLIPADST_ADST:
|
||||
load_buffer_16x16(input, in, stride, 1, 0, shift[0]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_col[txw_idx][txh_idx], col_num);
|
||||
col_txfm_16x16_rounding(out, -shift[1]);
|
||||
transpose_16x16(out, in);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx]);
|
||||
fadst16x16_sse4_1(in, out, fwd_cos_bit_row[txw_idx][txh_idx], col_num);
|
||||
transpose_16x16(out, in);
|
||||
write_buffer_16x16(in, coeff);
|
||||
break;
|
||||
|
|
@ -1585,3 +1638,146 @@ void av1_fwd_txfm2d_16x16_sse4_1(const int16_t *input, int32_t *coeff,
|
|||
}
|
||||
(void)bd;
|
||||
}
|
||||
|
||||
static INLINE void flip_buf_sse4_1(__m128i *in, __m128i *out, int size) {
|
||||
for (int i = 0; i < size; i += 2) in[30 - i] = out[i];
|
||||
for (int i = 1; i < size; i += 2) in[size - i] = out[i];
|
||||
}
|
||||
|
||||
static const fwd_transform_1d_sse4_1 col_highbd_txfm8x8_arr[TX_TYPES] = {
|
||||
fdct8x8_sse4_1, // DCT_DCT
|
||||
fadst8x8_sse4_1, // ADST_DCT
|
||||
fdct8x8_sse4_1, // DCT_ADST
|
||||
fadst8x8_sse4_1, // ADST_ADST
|
||||
fadst8x8_sse4_1, // FLIPADST_DCT
|
||||
fdct8x8_sse4_1, // DCT_FLIPADST
|
||||
fadst8x8_sse4_1, // FLIPADST_FLIPADST
|
||||
fadst8x8_sse4_1, // ADST_FLIPADST
|
||||
fadst8x8_sse4_1, // FLIPADST_ADST
|
||||
NULL, // IDTX
|
||||
NULL, // V_DCT
|
||||
NULL, // H_DCT
|
||||
NULL, // V_ADST
|
||||
NULL, // H_ADST
|
||||
NULL, // V_FLIPADST
|
||||
NULL // H_FLIPADST
|
||||
};
|
||||
|
||||
static const fwd_transform_1d_sse4_1 row_highbd_txfm8x16_arr[TX_TYPES] = {
|
||||
fdct16x16_sse4_1, // DCT_DCT
|
||||
fdct16x16_sse4_1, // ADST_DCT
|
||||
fadst16x16_sse4_1, // DCT_ADST
|
||||
fadst16x16_sse4_1, // ADST_ADST
|
||||
fdct16x16_sse4_1, // FLIPADST_DCT
|
||||
fadst16x16_sse4_1, // DCT_FLIPADST
|
||||
fadst16x16_sse4_1, // FLIPADST_FLIPADST
|
||||
fadst16x16_sse4_1, // ADST_FLIPADST
|
||||
fadst16x16_sse4_1, // FLIPADST_ADST
|
||||
NULL, // IDTX
|
||||
NULL, // V_DCT
|
||||
NULL, // H_DCT
|
||||
NULL, // V_ADST
|
||||
NULL, // H_ADST
|
||||
NULL, // V_FLIPADST
|
||||
NULL // H_FLIPADST
|
||||
};
|
||||
|
||||
static const fwd_transform_1d_sse4_1 col_highbd_txfm8x16_arr[TX_TYPES] = {
|
||||
fdct16x16_sse4_1, // DCT_DCT
|
||||
fadst16x16_sse4_1, // ADST_DCT
|
||||
fdct16x16_sse4_1, // DCT_ADST
|
||||
fadst16x16_sse4_1, // ADST_ADST
|
||||
fadst16x16_sse4_1, // FLIPADST_DCT
|
||||
fdct16x16_sse4_1, // DCT_FLIPADST
|
||||
fadst16x16_sse4_1, // FLIPADST_FLIPADST
|
||||
fadst16x16_sse4_1, // ADST_FLIPADST
|
||||
fadst16x16_sse4_1, // FLIPADST_ADST
|
||||
NULL, // IDTX
|
||||
NULL, // V_DCT
|
||||
NULL, // H_DCT
|
||||
NULL, // V_ADST
|
||||
NULL, // H_ADST
|
||||
NULL, // V_FLIPADST
|
||||
NULL // H_FLIPADST
|
||||
};
|
||||
static const fwd_transform_1d_sse4_1 row_highbd_txfm8x8_arr[TX_TYPES] = {
|
||||
fdct8x8_sse4_1, // DCT_DCT
|
||||
fdct8x8_sse4_1, // ADST_DCT
|
||||
fadst8x8_sse4_1, // DCT_ADST
|
||||
fadst8x8_sse4_1, // ADST_ADST
|
||||
fdct8x8_sse4_1, // FLIPADST_DCT
|
||||
fadst8x8_sse4_1, // DCT_FLIPADST
|
||||
fadst8x8_sse4_1, // FLIPADST_FLIPADST
|
||||
fadst8x8_sse4_1, // ADST_FLIPADST
|
||||
fadst8x8_sse4_1, // FLIPADST_ADST
|
||||
NULL, // IDTX
|
||||
NULL, // V_DCT
|
||||
NULL, // H_DCT
|
||||
NULL, // V_ADST
|
||||
NULL, // H_ADST
|
||||
NULL, // V_FLIPADST
|
||||
NULL // H_FLIPADST
|
||||
};
|
||||
|
||||
void av1_fwd_txfm2d_16x8_sse4_1(const int16_t *input, int32_t *coeff,
|
||||
int stride, TX_TYPE tx_type, int bd) {
|
||||
__m128i in[32], out[32];
|
||||
const int8_t *shift = fwd_txfm_shift_ls[TX_16X8];
|
||||
const int txw_idx = get_txw_idx(TX_16X8);
|
||||
const int txh_idx = get_txh_idx(TX_16X8);
|
||||
const fwd_transform_1d_sse4_1 col_txfm = col_highbd_txfm8x8_arr[tx_type];
|
||||
const fwd_transform_1d_sse4_1 row_txfm = row_highbd_txfm8x16_arr[tx_type];
|
||||
int bit = fwd_cos_bit_col[txw_idx][txh_idx];
|
||||
int ud_flip, lr_flip;
|
||||
get_flip_cfg(tx_type, &ud_flip, &lr_flip);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
load_buffer_8x8(input + i * 8, in, stride, ud_flip, 0, shift[0]);
|
||||
col_txfm(in, in, bit, 0);
|
||||
col_txfm_8x8_rounding(in, -shift[1]);
|
||||
transpose_8x8(in, out + i * 16);
|
||||
}
|
||||
|
||||
if (lr_flip) {
|
||||
flip_buf_sse4_1(in, out, 32);
|
||||
row_txfm(in, out, bit, 2);
|
||||
} else {
|
||||
row_txfm(out, out, bit, 2);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
transpose_8x8(out + i * 16, in);
|
||||
av1_round_shift_rect_array_32_sse4_1(in, in, 16, -shift[2], NewSqrt2);
|
||||
write_buffer_16x8(in, coeff + i * 8, 16);
|
||||
}
|
||||
|
||||
(void)bd;
|
||||
}
|
||||
|
||||
void av1_fwd_txfm2d_8x16_sse4_1(const int16_t *input, int32_t *coeff,
|
||||
int stride, TX_TYPE tx_type, int bd) {
|
||||
__m128i in[32], out[32];
|
||||
const int8_t *shift = fwd_txfm_shift_ls[TX_8X16];
|
||||
const int txw_idx = get_txw_idx(TX_8X16);
|
||||
const int txh_idx = get_txh_idx(TX_8X16);
|
||||
const fwd_transform_1d_sse4_1 col_txfm = col_highbd_txfm8x16_arr[tx_type];
|
||||
const fwd_transform_1d_sse4_1 row_txfm = row_highbd_txfm8x8_arr[tx_type];
|
||||
int bit = fwd_cos_bit_col[txw_idx][txh_idx];
|
||||
int ud_flip, lr_flip;
|
||||
get_flip_cfg(tx_type, &ud_flip, &lr_flip);
|
||||
|
||||
load_buffer_8x16(input, in, stride, ud_flip, lr_flip, shift[0]);
|
||||
col_txfm(in, in, bit, 2);
|
||||
col_txfm_8x16_rounding(in, -shift[1]);
|
||||
transpose_8x8(in, out);
|
||||
transpose_8x8(in + 16, out + 16);
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
row_txfm(out + i * 16, out, bit, 0);
|
||||
transpose_8x8(out, in);
|
||||
av1_round_shift_rect_array_32_sse4_1(in, in, 16, -shift[2], NewSqrt2);
|
||||
write_buffer_8x8(in, coeff + i * 64);
|
||||
}
|
||||
|
||||
(void)bd;
|
||||
}
|
||||
|
|
|
|||
403
third_party/aom/av1/encoder/x86/pickrst_avx2.c
vendored
Normal file
403
third_party/aom/av1/encoder/x86/pickrst_avx2.c
vendored
Normal file
|
|
@ -0,0 +1,403 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#include <immintrin.h> // AVX2
|
||||
#include "aom_dsp/x86/synonyms.h"
|
||||
#include "aom_dsp/x86/synonyms_avx2.h"
|
||||
#include "aom_dsp/x86/transpose_sse2.h"
|
||||
|
||||
#include "config/av1_rtcd.h"
|
||||
#include "av1/common/restoration.h"
|
||||
#include "av1/encoder/pickrst.h"
|
||||
|
||||
static INLINE void acc_stat_avx2(int32_t *dst, const uint8_t *src,
|
||||
const __m128i *shuffle, const __m256i *kl) {
|
||||
const __m128i s = _mm_shuffle_epi8(xx_loadu_128(src), *shuffle);
|
||||
const __m256i d0 = _mm256_madd_epi16(*kl, _mm256_cvtepu8_epi16(s));
|
||||
const __m256i dst0 = yy_loadu_256(dst);
|
||||
const __m256i r0 = _mm256_add_epi32(dst0, d0);
|
||||
yy_storeu_256(dst, r0);
|
||||
}
|
||||
|
||||
static INLINE void acc_stat_win7_one_line_avx2(
|
||||
const uint8_t *dgd, const uint8_t *src, int h_start, int h_end,
|
||||
int dgd_stride, const __m128i *shuffle, int32_t *sumX,
|
||||
int32_t sumY[WIENER_WIN][WIENER_WIN], int32_t M_int[WIENER_WIN][WIENER_WIN],
|
||||
int32_t H_int[WIENER_WIN2][WIENER_WIN * 8]) {
|
||||
int j, k, l;
|
||||
const int wiener_win = WIENER_WIN;
|
||||
for (j = h_start; j < h_end; j += 2) {
|
||||
const uint8_t X1 = src[j];
|
||||
const uint8_t X2 = src[j + 1];
|
||||
*sumX += X1 + X2;
|
||||
const uint8_t *dgd_ij = dgd + j;
|
||||
for (k = 0; k < wiener_win; k++) {
|
||||
const uint8_t *dgd_ijk = dgd_ij + k * dgd_stride;
|
||||
for (l = 0; l < wiener_win; l++) {
|
||||
int32_t *H_ = &H_int[(l * wiener_win + k)][0];
|
||||
const uint8_t D1 = dgd_ijk[l];
|
||||
const uint8_t D2 = dgd_ijk[l + 1];
|
||||
sumY[k][l] += D1 + D2;
|
||||
M_int[k][l] += D1 * X1 + D2 * X2;
|
||||
|
||||
const __m256i kl =
|
||||
_mm256_cvtepu8_epi16(_mm_set1_epi16(*((uint16_t *)(dgd_ijk + l))));
|
||||
acc_stat_avx2(H_ + 0 * 8, dgd_ij + 0 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_avx2(H_ + 1 * 8, dgd_ij + 1 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_avx2(H_ + 2 * 8, dgd_ij + 2 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_avx2(H_ + 3 * 8, dgd_ij + 3 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_avx2(H_ + 4 * 8, dgd_ij + 4 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_avx2(H_ + 5 * 8, dgd_ij + 5 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_avx2(H_ + 6 * 8, dgd_ij + 6 * dgd_stride, shuffle, &kl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void compute_stats_win7_opt_avx2(
|
||||
const uint8_t *dgd, const uint8_t *src, int h_start, int h_end, int v_start,
|
||||
int v_end, int dgd_stride, int src_stride, double *M, double *H) {
|
||||
int i, j, k, l, m, n;
|
||||
const int wiener_win = WIENER_WIN;
|
||||
const int pixel_count = (h_end - h_start) * (v_end - v_start);
|
||||
const int wiener_win2 = wiener_win * wiener_win;
|
||||
const int wiener_halfwin = (wiener_win >> 1);
|
||||
const double avg =
|
||||
find_average(dgd, h_start, h_end, v_start, v_end, dgd_stride);
|
||||
|
||||
int32_t M_int32[WIENER_WIN][WIENER_WIN] = { { 0 } };
|
||||
int64_t M_int64[WIENER_WIN][WIENER_WIN] = { { 0 } };
|
||||
int32_t H_int32[WIENER_WIN2][WIENER_WIN * 8] = { { 0 } };
|
||||
int64_t H_int64[WIENER_WIN2][WIENER_WIN * 8] = { { 0 } };
|
||||
int32_t sumY[WIENER_WIN][WIENER_WIN] = { { 0 } };
|
||||
int32_t sumX = 0;
|
||||
const uint8_t *dgd_win = dgd - wiener_halfwin * dgd_stride - wiener_halfwin;
|
||||
|
||||
const __m128i shuffle = xx_loadu_128(g_shuffle_stats_data);
|
||||
for (j = v_start; j < v_end; j += 64) {
|
||||
const int vert_end = AOMMIN(64, v_end - j) + j;
|
||||
for (i = j; i < vert_end; i++) {
|
||||
acc_stat_win7_one_line_avx2(
|
||||
dgd_win + i * dgd_stride, src + i * src_stride, h_start, h_end,
|
||||
dgd_stride, &shuffle, &sumX, sumY, M_int32, H_int32);
|
||||
}
|
||||
for (k = 0; k < wiener_win; ++k) {
|
||||
for (l = 0; l < wiener_win; ++l) {
|
||||
M_int64[k][l] += M_int32[k][l];
|
||||
M_int32[k][l] = 0;
|
||||
}
|
||||
}
|
||||
for (k = 0; k < WIENER_WIN2; ++k) {
|
||||
for (l = 0; l < WIENER_WIN * 8; ++l) {
|
||||
H_int64[k][l] += H_int32[k][l];
|
||||
H_int32[k][l] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const double avg_square_sum = avg * avg * pixel_count;
|
||||
for (k = 0; k < wiener_win; k++) {
|
||||
for (l = 0; l < wiener_win; l++) {
|
||||
const int32_t idx0 = l * wiener_win + k;
|
||||
M[idx0] = M_int64[k][l] + avg_square_sum - avg * (sumX + sumY[k][l]);
|
||||
double *H_ = H + idx0 * wiener_win2;
|
||||
int64_t *H_int_ = &H_int64[idx0][0];
|
||||
for (m = 0; m < wiener_win; m++) {
|
||||
for (n = 0; n < wiener_win; n++) {
|
||||
H_[m * wiener_win + n] = H_int_[n * 8 + m] + avg_square_sum -
|
||||
avg * (sumY[k][l] + sumY[n][m]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void acc_stat_win5_one_line_avx2(
|
||||
const uint8_t *dgd, const uint8_t *src, int h_start, int h_end,
|
||||
int dgd_stride, const __m128i *shuffle, int32_t *sumX,
|
||||
int32_t sumY[WIENER_WIN_CHROMA][WIENER_WIN_CHROMA],
|
||||
int32_t M_int[WIENER_WIN_CHROMA][WIENER_WIN_CHROMA],
|
||||
int32_t H_int[WIENER_WIN2_CHROMA][WIENER_WIN_CHROMA * 8]) {
|
||||
int j, k, l;
|
||||
const int wiener_win = WIENER_WIN_CHROMA;
|
||||
for (j = h_start; j < h_end; j += 2) {
|
||||
const uint8_t X1 = src[j];
|
||||
const uint8_t X2 = src[j + 1];
|
||||
*sumX += X1 + X2;
|
||||
const uint8_t *dgd_ij = dgd + j;
|
||||
for (k = 0; k < wiener_win; k++) {
|
||||
const uint8_t *dgd_ijk = dgd_ij + k * dgd_stride;
|
||||
for (l = 0; l < wiener_win; l++) {
|
||||
int32_t *H_ = &H_int[(l * wiener_win + k)][0];
|
||||
const uint8_t D1 = dgd_ijk[l];
|
||||
const uint8_t D2 = dgd_ijk[l + 1];
|
||||
sumY[k][l] += D1 + D2;
|
||||
M_int[k][l] += D1 * X1 + D2 * X2;
|
||||
|
||||
const __m256i kl =
|
||||
_mm256_cvtepu8_epi16(_mm_set1_epi16(*((uint16_t *)(dgd_ijk + l))));
|
||||
acc_stat_avx2(H_ + 0 * 8, dgd_ij + 0 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_avx2(H_ + 1 * 8, dgd_ij + 1 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_avx2(H_ + 2 * 8, dgd_ij + 2 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_avx2(H_ + 3 * 8, dgd_ij + 3 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_avx2(H_ + 4 * 8, dgd_ij + 4 * dgd_stride, shuffle, &kl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void compute_stats_win5_opt_avx2(
|
||||
const uint8_t *dgd, const uint8_t *src, int h_start, int h_end, int v_start,
|
||||
int v_end, int dgd_stride, int src_stride, double *M, double *H) {
|
||||
int i, j, k, l, m, n;
|
||||
const int wiener_win = WIENER_WIN_CHROMA;
|
||||
const int pixel_count = (h_end - h_start) * (v_end - v_start);
|
||||
const int wiener_win2 = wiener_win * wiener_win;
|
||||
const int wiener_halfwin = (wiener_win >> 1);
|
||||
const double avg =
|
||||
find_average(dgd, h_start, h_end, v_start, v_end, dgd_stride);
|
||||
|
||||
int32_t M_int32[WIENER_WIN_CHROMA][WIENER_WIN_CHROMA] = { { 0 } };
|
||||
int64_t M_int64[WIENER_WIN_CHROMA][WIENER_WIN_CHROMA] = { { 0 } };
|
||||
int32_t H_int32[WIENER_WIN2_CHROMA][WIENER_WIN_CHROMA * 8] = { { 0 } };
|
||||
int64_t H_int64[WIENER_WIN2_CHROMA][WIENER_WIN_CHROMA * 8] = { { 0 } };
|
||||
int32_t sumY[WIENER_WIN_CHROMA][WIENER_WIN_CHROMA] = { { 0 } };
|
||||
int32_t sumX = 0;
|
||||
const uint8_t *dgd_win = dgd - wiener_halfwin * dgd_stride - wiener_halfwin;
|
||||
|
||||
const __m128i shuffle = xx_loadu_128(g_shuffle_stats_data);
|
||||
for (j = v_start; j < v_end; j += 64) {
|
||||
const int vert_end = AOMMIN(64, v_end - j) + j;
|
||||
for (i = j; i < vert_end; i++) {
|
||||
acc_stat_win5_one_line_avx2(
|
||||
dgd_win + i * dgd_stride, src + i * src_stride, h_start, h_end,
|
||||
dgd_stride, &shuffle, &sumX, sumY, M_int32, H_int32);
|
||||
}
|
||||
for (k = 0; k < wiener_win; ++k) {
|
||||
for (l = 0; l < wiener_win; ++l) {
|
||||
M_int64[k][l] += M_int32[k][l];
|
||||
M_int32[k][l] = 0;
|
||||
}
|
||||
}
|
||||
for (k = 0; k < WIENER_WIN2_CHROMA; ++k) {
|
||||
for (l = 0; l < WIENER_WIN_CHROMA * 8; ++l) {
|
||||
H_int64[k][l] += H_int32[k][l];
|
||||
H_int32[k][l] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const double avg_square_sum = avg * avg * pixel_count;
|
||||
for (k = 0; k < wiener_win; k++) {
|
||||
for (l = 0; l < wiener_win; l++) {
|
||||
const int32_t idx0 = l * wiener_win + k;
|
||||
M[idx0] = M_int64[k][l] + avg_square_sum - avg * (sumX + sumY[k][l]);
|
||||
double *H_ = H + idx0 * wiener_win2;
|
||||
int64_t *H_int_ = &H_int64[idx0][0];
|
||||
for (m = 0; m < wiener_win; m++) {
|
||||
for (n = 0; n < wiener_win; n++) {
|
||||
H_[m * wiener_win + n] = H_int_[n * 8 + m] + avg_square_sum -
|
||||
avg * (sumY[k][l] + sumY[n][m]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void av1_compute_stats_avx2(int wiener_win, const uint8_t *dgd,
|
||||
const uint8_t *src, int h_start, int h_end,
|
||||
int v_start, int v_end, int dgd_stride,
|
||||
int src_stride, double *M, double *H) {
|
||||
if (wiener_win == WIENER_WIN) {
|
||||
compute_stats_win7_opt_avx2(dgd, src, h_start, h_end, v_start, v_end,
|
||||
dgd_stride, src_stride, M, H);
|
||||
} else if (wiener_win == WIENER_WIN_CHROMA) {
|
||||
compute_stats_win5_opt_avx2(dgd, src, h_start, h_end, v_start, v_end,
|
||||
dgd_stride, src_stride, M, H);
|
||||
} else {
|
||||
av1_compute_stats_c(wiener_win, dgd, src, h_start, h_end, v_start, v_end,
|
||||
dgd_stride, src_stride, M, H);
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE __m256i pair_set_epi16(uint16_t a, uint16_t b) {
|
||||
return _mm256_set1_epi32(
|
||||
(int32_t)(((uint16_t)(a)) | (((uint32_t)(b)) << 16)));
|
||||
}
|
||||
|
||||
int64_t av1_lowbd_pixel_proj_error_avx2(
|
||||
const uint8_t *src8, int width, int height, int src_stride,
|
||||
const uint8_t *dat8, int dat_stride, int32_t *flt0, int flt0_stride,
|
||||
int32_t *flt1, int flt1_stride, int xq[2], const sgr_params_type *params) {
|
||||
int i, j, k;
|
||||
const int32_t shift = SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS;
|
||||
const __m256i rounding = _mm256_set1_epi32(1 << (shift - 1));
|
||||
__m256i sum64 = _mm256_setzero_si256();
|
||||
const uint8_t *src = src8;
|
||||
const uint8_t *dat = dat8;
|
||||
int64_t err = 0;
|
||||
if (params->r[0] > 0 && params->r[1] > 0) {
|
||||
__m256i xq_coeff = pair_set_epi16(xq[0], xq[1]);
|
||||
for (i = 0; i < height; ++i) {
|
||||
__m256i sum32 = _mm256_setzero_si256();
|
||||
for (j = 0; j <= width - 16; j += 16) {
|
||||
const __m256i d0 = _mm256_cvtepu8_epi16(xx_loadu_128(dat + j));
|
||||
const __m256i s0 = _mm256_cvtepu8_epi16(xx_loadu_128(src + j));
|
||||
const __m256i flt0_16b = _mm256_permute4x64_epi64(
|
||||
_mm256_packs_epi32(yy_loadu_256(flt0 + j),
|
||||
yy_loadu_256(flt0 + j + 8)),
|
||||
0xd8);
|
||||
const __m256i flt1_16b = _mm256_permute4x64_epi64(
|
||||
_mm256_packs_epi32(yy_loadu_256(flt1 + j),
|
||||
yy_loadu_256(flt1 + j + 8)),
|
||||
0xd8);
|
||||
const __m256i u0 = _mm256_slli_epi16(d0, SGRPROJ_RST_BITS);
|
||||
const __m256i flt0_0_sub_u = _mm256_sub_epi16(flt0_16b, u0);
|
||||
const __m256i flt1_0_sub_u = _mm256_sub_epi16(flt1_16b, u0);
|
||||
const __m256i v0 = _mm256_madd_epi16(
|
||||
xq_coeff, _mm256_unpacklo_epi16(flt0_0_sub_u, flt1_0_sub_u));
|
||||
const __m256i v1 = _mm256_madd_epi16(
|
||||
xq_coeff, _mm256_unpackhi_epi16(flt0_0_sub_u, flt1_0_sub_u));
|
||||
const __m256i vr0 =
|
||||
_mm256_srai_epi32(_mm256_add_epi32(v0, rounding), shift);
|
||||
const __m256i vr1 =
|
||||
_mm256_srai_epi32(_mm256_add_epi32(v1, rounding), shift);
|
||||
const __m256i e0 = _mm256_sub_epi16(
|
||||
_mm256_add_epi16(_mm256_packs_epi32(vr0, vr1), d0), s0);
|
||||
const __m256i err0 = _mm256_madd_epi16(e0, e0);
|
||||
sum32 = _mm256_add_epi32(sum32, err0);
|
||||
}
|
||||
for (k = j; k < width; ++k) {
|
||||
const int32_t u = (int32_t)(dat[k] << SGRPROJ_RST_BITS);
|
||||
int32_t v = xq[0] * (flt0[k] - u) + xq[1] * (flt1[k] - u);
|
||||
const int32_t e = ROUND_POWER_OF_TWO(v, shift) + dat[k] - src[k];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
flt0 += flt0_stride;
|
||||
flt1 += flt1_stride;
|
||||
const __m256i sum64_0 =
|
||||
_mm256_cvtepi32_epi64(_mm256_castsi256_si128(sum32));
|
||||
const __m256i sum64_1 =
|
||||
_mm256_cvtepi32_epi64(_mm256_extracti128_si256(sum32, 1));
|
||||
sum64 = _mm256_add_epi64(sum64, sum64_0);
|
||||
sum64 = _mm256_add_epi64(sum64, sum64_1);
|
||||
}
|
||||
} else if (params->r[0] > 0) {
|
||||
__m256i xq_coeff =
|
||||
pair_set_epi16(xq[0], (-xq[0] * (1 << SGRPROJ_RST_BITS)));
|
||||
for (i = 0; i < height; ++i) {
|
||||
__m256i sum32 = _mm256_setzero_si256();
|
||||
for (j = 0; j <= width - 16; j += 16) {
|
||||
const __m256i d0 = _mm256_cvtepu8_epi16(xx_loadu_128(dat + j));
|
||||
const __m256i s0 = _mm256_cvtepu8_epi16(xx_loadu_128(src + j));
|
||||
const __m256i flt0_16b = _mm256_permute4x64_epi64(
|
||||
_mm256_packs_epi32(yy_loadu_256(flt0 + j),
|
||||
yy_loadu_256(flt0 + j + 8)),
|
||||
0xd8);
|
||||
const __m256i v0 =
|
||||
_mm256_madd_epi16(xq_coeff, _mm256_unpacklo_epi16(flt0_16b, d0));
|
||||
const __m256i v1 =
|
||||
_mm256_madd_epi16(xq_coeff, _mm256_unpackhi_epi16(flt0_16b, d0));
|
||||
const __m256i vr0 =
|
||||
_mm256_srai_epi32(_mm256_add_epi32(v0, rounding), shift);
|
||||
const __m256i vr1 =
|
||||
_mm256_srai_epi32(_mm256_add_epi32(v1, rounding), shift);
|
||||
const __m256i e0 = _mm256_sub_epi16(
|
||||
_mm256_add_epi16(_mm256_packs_epi32(vr0, vr1), d0), s0);
|
||||
const __m256i err0 = _mm256_madd_epi16(e0, e0);
|
||||
sum32 = _mm256_add_epi32(sum32, err0);
|
||||
}
|
||||
for (k = j; k < width; ++k) {
|
||||
const int32_t u = (int32_t)(dat[k] << SGRPROJ_RST_BITS);
|
||||
int32_t v = xq[0] * (flt0[k] - u);
|
||||
const int32_t e = ROUND_POWER_OF_TWO(v, shift) + dat[k] - src[k];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
flt0 += flt0_stride;
|
||||
const __m256i sum64_0 =
|
||||
_mm256_cvtepi32_epi64(_mm256_castsi256_si128(sum32));
|
||||
const __m256i sum64_1 =
|
||||
_mm256_cvtepi32_epi64(_mm256_extracti128_si256(sum32, 1));
|
||||
sum64 = _mm256_add_epi64(sum64, sum64_0);
|
||||
sum64 = _mm256_add_epi64(sum64, sum64_1);
|
||||
}
|
||||
} else if (params->r[1] > 0) {
|
||||
__m256i xq_coeff = pair_set_epi16(xq[1], -(xq[1] << SGRPROJ_RST_BITS));
|
||||
for (i = 0; i < height; ++i) {
|
||||
__m256i sum32 = _mm256_setzero_si256();
|
||||
for (j = 0; j <= width - 16; j += 16) {
|
||||
const __m256i d0 = _mm256_cvtepu8_epi16(xx_loadu_128(dat + j));
|
||||
const __m256i s0 = _mm256_cvtepu8_epi16(xx_loadu_128(src + j));
|
||||
const __m256i flt1_16b = _mm256_permute4x64_epi64(
|
||||
_mm256_packs_epi32(yy_loadu_256(flt1 + j),
|
||||
yy_loadu_256(flt1 + j + 8)),
|
||||
0xd8);
|
||||
const __m256i v0 =
|
||||
_mm256_madd_epi16(xq_coeff, _mm256_unpacklo_epi16(flt1_16b, d0));
|
||||
const __m256i v1 =
|
||||
_mm256_madd_epi16(xq_coeff, _mm256_unpackhi_epi16(flt1_16b, d0));
|
||||
const __m256i vr0 =
|
||||
_mm256_srai_epi32(_mm256_add_epi32(v0, rounding), shift);
|
||||
const __m256i vr1 =
|
||||
_mm256_srai_epi32(_mm256_add_epi32(v1, rounding), shift);
|
||||
const __m256i e0 = _mm256_sub_epi16(
|
||||
_mm256_add_epi16(_mm256_packs_epi32(vr0, vr1), d0), s0);
|
||||
const __m256i err0 = _mm256_madd_epi16(e0, e0);
|
||||
sum32 = _mm256_add_epi32(sum32, err0);
|
||||
}
|
||||
for (k = j; k < width; ++k) {
|
||||
const int32_t u = (int32_t)(dat[k] << SGRPROJ_RST_BITS);
|
||||
int32_t v = xq[1] * (flt1[k] - u);
|
||||
const int32_t e = ROUND_POWER_OF_TWO(v, shift) + dat[k] - src[k];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
flt1 += flt1_stride;
|
||||
const __m256i sum64_0 =
|
||||
_mm256_cvtepi32_epi64(_mm256_castsi256_si128(sum32));
|
||||
const __m256i sum64_1 =
|
||||
_mm256_cvtepi32_epi64(_mm256_extracti128_si256(sum32, 1));
|
||||
sum64 = _mm256_add_epi64(sum64, sum64_0);
|
||||
sum64 = _mm256_add_epi64(sum64, sum64_1);
|
||||
}
|
||||
} else {
|
||||
__m256i sum32 = _mm256_setzero_si256();
|
||||
for (i = 0; i < height; ++i) {
|
||||
for (j = 0; j <= width - 16; j += 16) {
|
||||
const __m256i d0 = _mm256_cvtepu8_epi16(xx_loadu_128(dat + j));
|
||||
const __m256i s0 = _mm256_cvtepu8_epi16(xx_loadu_128(src + j));
|
||||
const __m256i diff0 = _mm256_sub_epi16(d0, s0);
|
||||
const __m256i err0 = _mm256_madd_epi16(diff0, diff0);
|
||||
sum32 = _mm256_add_epi32(sum32, err0);
|
||||
}
|
||||
for (k = j; k < width; ++k) {
|
||||
const int32_t e = (int32_t)(dat[k]) - src[k];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
}
|
||||
const __m256i sum64_0 =
|
||||
_mm256_cvtepi32_epi64(_mm256_castsi256_si128(sum32));
|
||||
const __m256i sum64_1 =
|
||||
_mm256_cvtepi32_epi64(_mm256_extracti128_si256(sum32, 1));
|
||||
sum64 = _mm256_add_epi64(sum64_0, sum64_1);
|
||||
}
|
||||
int64_t sum[4];
|
||||
yy_storeu_256(sum, sum64);
|
||||
err += sum[0] + sum[1] + sum[2] + sum[3];
|
||||
return err;
|
||||
}
|
||||
389
third_party/aom/av1/encoder/x86/pickrst_sse4.c
vendored
Normal file
389
third_party/aom/av1/encoder/x86/pickrst_sse4.c
vendored
Normal file
|
|
@ -0,0 +1,389 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Alliance for Open Media. All rights reserved
|
||||
*
|
||||
* This source code is subject to the terms of the BSD 2 Clause License and
|
||||
* the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
|
||||
* was not distributed with this source code in the LICENSE file, you can
|
||||
* obtain it at www.aomedia.org/license/software. If the Alliance for Open
|
||||
* Media Patent License 1.0 was not distributed with this source code in the
|
||||
* PATENTS file, you can obtain it at www.aomedia.org/license/patent.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <emmintrin.h>
|
||||
#include "aom_dsp/x86/synonyms.h"
|
||||
|
||||
#include "config/av1_rtcd.h"
|
||||
#include "av1/common/restoration.h"
|
||||
#include "av1/encoder/pickrst.h"
|
||||
|
||||
static INLINE void acc_stat_sse41(int32_t *dst, const uint8_t *src,
|
||||
const __m128i *shuffle, const __m128i *kl) {
|
||||
const __m128i s = _mm_shuffle_epi8(xx_loadu_128(src), *shuffle);
|
||||
const __m128i d0 = _mm_madd_epi16(*kl, _mm_cvtepu8_epi16(s));
|
||||
const __m128i d1 =
|
||||
_mm_madd_epi16(*kl, _mm_cvtepu8_epi16(_mm_srli_si128(s, 8)));
|
||||
const __m128i dst0 = xx_loadu_128(dst);
|
||||
const __m128i dst1 = xx_loadu_128(dst + 4);
|
||||
const __m128i r0 = _mm_add_epi32(dst0, d0);
|
||||
const __m128i r1 = _mm_add_epi32(dst1, d1);
|
||||
xx_storeu_128(dst, r0);
|
||||
xx_storeu_128(dst + 4, r1);
|
||||
}
|
||||
|
||||
static INLINE void acc_stat_win7_one_line_sse4_1(
|
||||
const uint8_t *dgd, const uint8_t *src, int h_start, int h_end,
|
||||
int dgd_stride, const __m128i *shuffle, int32_t *sumX,
|
||||
int32_t sumY[WIENER_WIN][WIENER_WIN], int32_t M_int[WIENER_WIN][WIENER_WIN],
|
||||
int32_t H_int[WIENER_WIN2][WIENER_WIN * 8]) {
|
||||
const int wiener_win = 7;
|
||||
int j, k, l;
|
||||
for (j = h_start; j < h_end; j += 2) {
|
||||
const uint8_t *dgd_ij = dgd + j;
|
||||
const uint8_t X1 = src[j];
|
||||
const uint8_t X2 = src[j + 1];
|
||||
*sumX += X1 + X2;
|
||||
for (k = 0; k < wiener_win; k++) {
|
||||
const uint8_t *dgd_ijk = dgd_ij + k * dgd_stride;
|
||||
for (l = 0; l < wiener_win; l++) {
|
||||
int32_t *H_ = &H_int[(l * wiener_win + k)][0];
|
||||
const uint8_t D1 = dgd_ijk[l];
|
||||
const uint8_t D2 = dgd_ijk[l + 1];
|
||||
sumY[k][l] += D1 + D2;
|
||||
M_int[k][l] += D1 * X1 + D2 * X2;
|
||||
|
||||
const __m128i kl =
|
||||
_mm_cvtepu8_epi16(_mm_set1_epi16(*((uint16_t *)(dgd_ijk + l))));
|
||||
acc_stat_sse41(H_ + 0 * 8, dgd_ij + 0 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_sse41(H_ + 1 * 8, dgd_ij + 1 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_sse41(H_ + 2 * 8, dgd_ij + 2 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_sse41(H_ + 3 * 8, dgd_ij + 3 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_sse41(H_ + 4 * 8, dgd_ij + 4 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_sse41(H_ + 5 * 8, dgd_ij + 5 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_sse41(H_ + 6 * 8, dgd_ij + 6 * dgd_stride, shuffle, &kl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void compute_stats_win7_opt_sse4_1(
|
||||
const uint8_t *dgd, const uint8_t *src, int h_start, int h_end, int v_start,
|
||||
int v_end, int dgd_stride, int src_stride, double *M, double *H) {
|
||||
int i, j, k, l, m, n;
|
||||
const int wiener_win = WIENER_WIN;
|
||||
const int pixel_count = (h_end - h_start) * (v_end - v_start);
|
||||
const int wiener_win2 = wiener_win * wiener_win;
|
||||
const int wiener_halfwin = (wiener_win >> 1);
|
||||
const double avg =
|
||||
find_average(dgd, h_start, h_end, v_start, v_end, dgd_stride);
|
||||
|
||||
int32_t M_int32[WIENER_WIN][WIENER_WIN] = { { 0 } };
|
||||
int64_t M_int64[WIENER_WIN][WIENER_WIN] = { { 0 } };
|
||||
int32_t H_int32[WIENER_WIN2][WIENER_WIN * 8] = { { 0 } };
|
||||
int64_t H_int64[WIENER_WIN2][WIENER_WIN * 8] = { { 0 } };
|
||||
int32_t sumY[WIENER_WIN][WIENER_WIN] = { { 0 } };
|
||||
int32_t sumX = 0;
|
||||
const uint8_t *dgd_win = dgd - wiener_halfwin * dgd_stride - wiener_halfwin;
|
||||
|
||||
const __m128i shuffle = xx_loadu_128(g_shuffle_stats_data);
|
||||
for (j = v_start; j < v_end; j += 64) {
|
||||
const int vert_end = AOMMIN(64, v_end - j) + j;
|
||||
for (i = j; i < vert_end; i++) {
|
||||
acc_stat_win7_one_line_sse4_1(
|
||||
dgd_win + i * dgd_stride, src + i * src_stride, h_start, h_end,
|
||||
dgd_stride, &shuffle, &sumX, sumY, M_int32, H_int32);
|
||||
}
|
||||
for (k = 0; k < wiener_win; ++k) {
|
||||
for (l = 0; l < wiener_win; ++l) {
|
||||
M_int64[k][l] += M_int32[k][l];
|
||||
M_int32[k][l] = 0;
|
||||
}
|
||||
}
|
||||
for (k = 0; k < WIENER_WIN2; ++k) {
|
||||
for (l = 0; l < WIENER_WIN * 8; ++l) {
|
||||
H_int64[k][l] += H_int32[k][l];
|
||||
H_int32[k][l] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const double avg_square_sum = avg * avg * pixel_count;
|
||||
for (k = 0; k < wiener_win; k++) {
|
||||
for (l = 0; l < wiener_win; l++) {
|
||||
const int32_t idx0 = l * wiener_win + k;
|
||||
M[idx0] = M_int64[k][l] + avg_square_sum - avg * (sumX + sumY[k][l]);
|
||||
double *H_ = H + idx0 * wiener_win2;
|
||||
int64_t *H_int_ = &H_int64[idx0][0];
|
||||
for (m = 0; m < wiener_win; m++) {
|
||||
for (n = 0; n < wiener_win; n++) {
|
||||
H_[m * wiener_win + n] = H_int_[n * 8 + m] + avg_square_sum -
|
||||
avg * (sumY[k][l] + sumY[n][m]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void acc_stat_win5_one_line_sse4_1(
|
||||
const uint8_t *dgd, const uint8_t *src, int h_start, int h_end,
|
||||
int dgd_stride, const __m128i *shuffle, int32_t *sumX,
|
||||
int32_t sumY[WIENER_WIN_CHROMA][WIENER_WIN_CHROMA],
|
||||
int32_t M_int[WIENER_WIN_CHROMA][WIENER_WIN_CHROMA],
|
||||
int32_t H_int[WIENER_WIN2_CHROMA][WIENER_WIN_CHROMA * 8]) {
|
||||
const int wiener_win = WIENER_WIN_CHROMA;
|
||||
int j, k, l;
|
||||
for (j = h_start; j < h_end; j += 2) {
|
||||
const uint8_t *dgd_ij = dgd + j;
|
||||
const uint8_t X1 = src[j];
|
||||
const uint8_t X2 = src[j + 1];
|
||||
*sumX += X1 + X2;
|
||||
for (k = 0; k < wiener_win; k++) {
|
||||
const uint8_t *dgd_ijk = dgd_ij + k * dgd_stride;
|
||||
for (l = 0; l < wiener_win; l++) {
|
||||
int32_t *H_ = &H_int[(l * wiener_win + k)][0];
|
||||
const uint8_t D1 = dgd_ijk[l];
|
||||
const uint8_t D2 = dgd_ijk[l + 1];
|
||||
sumY[k][l] += D1 + D2;
|
||||
M_int[k][l] += D1 * X1 + D2 * X2;
|
||||
|
||||
const __m128i kl =
|
||||
_mm_cvtepu8_epi16(_mm_set1_epi16(*((uint16_t *)(dgd_ijk + l))));
|
||||
acc_stat_sse41(H_ + 0 * 8, dgd_ij + 0 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_sse41(H_ + 1 * 8, dgd_ij + 1 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_sse41(H_ + 2 * 8, dgd_ij + 2 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_sse41(H_ + 3 * 8, dgd_ij + 3 * dgd_stride, shuffle, &kl);
|
||||
acc_stat_sse41(H_ + 4 * 8, dgd_ij + 4 * dgd_stride, shuffle, &kl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE void compute_stats_win5_opt_sse4_1(
|
||||
const uint8_t *dgd, const uint8_t *src, int h_start, int h_end, int v_start,
|
||||
int v_end, int dgd_stride, int src_stride, double *M, double *H) {
|
||||
int i, j, k, l, m, n;
|
||||
const int wiener_win = WIENER_WIN_CHROMA;
|
||||
const int pixel_count = (h_end - h_start) * (v_end - v_start);
|
||||
const int wiener_win2 = wiener_win * wiener_win;
|
||||
const int wiener_halfwin = (wiener_win >> 1);
|
||||
const double avg =
|
||||
find_average(dgd, h_start, h_end, v_start, v_end, dgd_stride);
|
||||
|
||||
int32_t M_int32[WIENER_WIN_CHROMA][WIENER_WIN_CHROMA] = { { 0 } };
|
||||
int64_t M_int64[WIENER_WIN_CHROMA][WIENER_WIN_CHROMA] = { { 0 } };
|
||||
int32_t H_int32[WIENER_WIN2_CHROMA][WIENER_WIN_CHROMA * 8] = { { 0 } };
|
||||
int64_t H_int64[WIENER_WIN2_CHROMA][WIENER_WIN_CHROMA * 8] = { { 0 } };
|
||||
int32_t sumY[WIENER_WIN_CHROMA][WIENER_WIN_CHROMA] = { { 0 } };
|
||||
int32_t sumX = 0;
|
||||
const uint8_t *dgd_win = dgd - wiener_halfwin * dgd_stride - wiener_halfwin;
|
||||
|
||||
const __m128i shuffle = xx_loadu_128(g_shuffle_stats_data);
|
||||
for (j = v_start; j < v_end; j += 64) {
|
||||
const int vert_end = AOMMIN(64, v_end - j) + j;
|
||||
for (i = j; i < vert_end; i++) {
|
||||
acc_stat_win5_one_line_sse4_1(
|
||||
dgd_win + i * dgd_stride, src + i * src_stride, h_start, h_end,
|
||||
dgd_stride, &shuffle, &sumX, sumY, M_int32, H_int32);
|
||||
}
|
||||
for (k = 0; k < wiener_win; ++k) {
|
||||
for (l = 0; l < wiener_win; ++l) {
|
||||
M_int64[k][l] += M_int32[k][l];
|
||||
M_int32[k][l] = 0;
|
||||
}
|
||||
}
|
||||
for (k = 0; k < WIENER_WIN_CHROMA * WIENER_WIN_CHROMA; ++k) {
|
||||
for (l = 0; l < WIENER_WIN_CHROMA * 8; ++l) {
|
||||
H_int64[k][l] += H_int32[k][l];
|
||||
H_int32[k][l] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const double avg_square_sum = avg * avg * pixel_count;
|
||||
for (k = 0; k < wiener_win; k++) {
|
||||
for (l = 0; l < wiener_win; l++) {
|
||||
const int32_t idx0 = l * wiener_win + k;
|
||||
M[idx0] = M_int64[k][l] + avg_square_sum - avg * (sumX + sumY[k][l]);
|
||||
double *H_ = H + idx0 * wiener_win2;
|
||||
int64_t *H_int_ = &H_int64[idx0][0];
|
||||
for (m = 0; m < wiener_win; m++) {
|
||||
for (n = 0; n < wiener_win; n++) {
|
||||
H_[m * wiener_win + n] = H_int_[n * 8 + m] + avg_square_sum -
|
||||
avg * (sumY[k][l] + sumY[n][m]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
void av1_compute_stats_sse4_1(int wiener_win, const uint8_t *dgd,
|
||||
const uint8_t *src, int h_start, int h_end,
|
||||
int v_start, int v_end, int dgd_stride,
|
||||
int src_stride, double *M, double *H) {
|
||||
if (wiener_win == WIENER_WIN) {
|
||||
compute_stats_win7_opt_sse4_1(dgd, src, h_start, h_end, v_start, v_end,
|
||||
dgd_stride, src_stride, M, H);
|
||||
} else if (wiener_win == WIENER_WIN_CHROMA) {
|
||||
compute_stats_win5_opt_sse4_1(dgd, src, h_start, h_end, v_start, v_end,
|
||||
dgd_stride, src_stride, M, H);
|
||||
} else {
|
||||
av1_compute_stats_c(wiener_win, dgd, src, h_start, h_end, v_start, v_end,
|
||||
dgd_stride, src_stride, M, H);
|
||||
}
|
||||
}
|
||||
|
||||
static INLINE __m128i pair_set_epi16(uint16_t a, uint16_t b) {
|
||||
return _mm_set1_epi32((int32_t)(((uint16_t)(a)) | (((uint32_t)(b)) << 16)));
|
||||
}
|
||||
|
||||
int64_t av1_lowbd_pixel_proj_error_sse4_1(
|
||||
const uint8_t *src8, int width, int height, int src_stride,
|
||||
const uint8_t *dat8, int dat_stride, int32_t *flt0, int flt0_stride,
|
||||
int32_t *flt1, int flt1_stride, int xq[2], const sgr_params_type *params) {
|
||||
int i, j, k;
|
||||
const int32_t shift = SGRPROJ_RST_BITS + SGRPROJ_PRJ_BITS;
|
||||
const __m128i rounding = _mm_set1_epi32(1 << (shift - 1));
|
||||
__m128i sum64 = _mm_setzero_si128();
|
||||
const uint8_t *src = src8;
|
||||
const uint8_t *dat = dat8;
|
||||
int64_t err = 0;
|
||||
if (params->r[0] > 0 && params->r[1] > 0) {
|
||||
__m128i xq_coeff = pair_set_epi16(xq[0], xq[1]);
|
||||
for (i = 0; i < height; ++i) {
|
||||
__m128i sum32 = _mm_setzero_si128();
|
||||
for (j = 0; j < width - 8; j += 8) {
|
||||
const __m128i d0 = _mm_cvtepu8_epi16(xx_loadl_64(dat + j));
|
||||
const __m128i s0 = _mm_cvtepu8_epi16(xx_loadl_64(src + j));
|
||||
const __m128i flt0_16b =
|
||||
_mm_packs_epi32(xx_loadu_128(flt0 + j), xx_loadu_128(flt0 + j + 4));
|
||||
const __m128i flt1_16b =
|
||||
_mm_packs_epi32(xx_loadu_128(flt1 + j), xx_loadu_128(flt1 + j + 4));
|
||||
const __m128i u0 = _mm_slli_epi16(d0, SGRPROJ_RST_BITS);
|
||||
const __m128i flt0_0_sub_u = _mm_sub_epi16(flt0_16b, u0);
|
||||
const __m128i flt1_0_sub_u = _mm_sub_epi16(flt1_16b, u0);
|
||||
const __m128i v0 = _mm_madd_epi16(
|
||||
xq_coeff, _mm_unpacklo_epi16(flt0_0_sub_u, flt1_0_sub_u));
|
||||
const __m128i v1 = _mm_madd_epi16(
|
||||
xq_coeff, _mm_unpackhi_epi16(flt0_0_sub_u, flt1_0_sub_u));
|
||||
const __m128i vr0 = _mm_srai_epi32(_mm_add_epi32(v0, rounding), shift);
|
||||
const __m128i vr1 = _mm_srai_epi32(_mm_add_epi32(v1, rounding), shift);
|
||||
const __m128i e0 =
|
||||
_mm_sub_epi16(_mm_add_epi16(_mm_packs_epi32(vr0, vr1), d0), s0);
|
||||
const __m128i err0 = _mm_madd_epi16(e0, e0);
|
||||
sum32 = _mm_add_epi32(sum32, err0);
|
||||
}
|
||||
for (k = j; k < width; ++k) {
|
||||
const int32_t u = (int32_t)(dat[k] << SGRPROJ_RST_BITS);
|
||||
int32_t v = xq[0] * (flt0[k] - u) + xq[1] * (flt1[k] - u);
|
||||
const int32_t e = ROUND_POWER_OF_TWO(v, shift) + dat[k] - src[k];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
flt0 += flt0_stride;
|
||||
flt1 += flt1_stride;
|
||||
const __m128i sum64_0 = _mm_cvtepi32_epi64(sum32);
|
||||
const __m128i sum64_1 = _mm_cvtepi32_epi64(_mm_srli_si128(sum32, 8));
|
||||
sum64 = _mm_add_epi64(sum64, sum64_0);
|
||||
sum64 = _mm_add_epi64(sum64, sum64_1);
|
||||
}
|
||||
} else if (params->r[0] > 0) {
|
||||
__m128i xq_coeff = pair_set_epi16(xq[0], -(xq[0] << SGRPROJ_RST_BITS));
|
||||
for (i = 0; i < height; ++i) {
|
||||
__m128i sum32 = _mm_setzero_si128();
|
||||
for (j = 0; j < width - 8; j += 8) {
|
||||
const __m128i d0 = _mm_cvtepu8_epi16(xx_loadl_64(dat + j));
|
||||
const __m128i s0 = _mm_cvtepu8_epi16(xx_loadl_64(src + j));
|
||||
const __m128i flt0_16b =
|
||||
_mm_packs_epi32(xx_loadu_128(flt0 + j), xx_loadu_128(flt0 + j + 4));
|
||||
const __m128i v0 =
|
||||
_mm_madd_epi16(xq_coeff, _mm_unpacklo_epi16(flt0_16b, d0));
|
||||
const __m128i v1 =
|
||||
_mm_madd_epi16(xq_coeff, _mm_unpackhi_epi16(flt0_16b, d0));
|
||||
const __m128i vr0 = _mm_srai_epi32(_mm_add_epi32(v0, rounding), shift);
|
||||
const __m128i vr1 = _mm_srai_epi32(_mm_add_epi32(v1, rounding), shift);
|
||||
const __m128i e0 =
|
||||
_mm_sub_epi16(_mm_add_epi16(_mm_packs_epi32(vr0, vr1), d0), s0);
|
||||
const __m128i err0 = _mm_madd_epi16(e0, e0);
|
||||
sum32 = _mm_add_epi32(sum32, err0);
|
||||
}
|
||||
for (k = j; k < width; ++k) {
|
||||
const int32_t u = (int32_t)(dat[k] << SGRPROJ_RST_BITS);
|
||||
int32_t v = xq[0] * (flt0[k] - u);
|
||||
const int32_t e = ROUND_POWER_OF_TWO(v, shift) + dat[k] - src[k];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
flt0 += flt0_stride;
|
||||
const __m128i sum64_0 = _mm_cvtepi32_epi64(sum32);
|
||||
const __m128i sum64_1 = _mm_cvtepi32_epi64(_mm_srli_si128(sum32, 8));
|
||||
sum64 = _mm_add_epi64(sum64, sum64_0);
|
||||
sum64 = _mm_add_epi64(sum64, sum64_1);
|
||||
}
|
||||
} else if (params->r[1] > 0) {
|
||||
__m128i xq_coeff = pair_set_epi16(xq[1], -(xq[1] << SGRPROJ_RST_BITS));
|
||||
for (i = 0; i < height; ++i) {
|
||||
__m128i sum32 = _mm_setzero_si128();
|
||||
for (j = 0; j < width - 8; j += 8) {
|
||||
const __m128i d0 = _mm_cvtepu8_epi16(xx_loadl_64(dat + j));
|
||||
const __m128i s0 = _mm_cvtepu8_epi16(xx_loadl_64(src + j));
|
||||
const __m128i flt1_16b =
|
||||
_mm_packs_epi32(xx_loadu_128(flt1 + j), xx_loadu_128(flt1 + j + 4));
|
||||
const __m128i v0 =
|
||||
_mm_madd_epi16(xq_coeff, _mm_unpacklo_epi16(flt1_16b, d0));
|
||||
const __m128i v1 =
|
||||
_mm_madd_epi16(xq_coeff, _mm_unpackhi_epi16(flt1_16b, d0));
|
||||
const __m128i vr0 = _mm_srai_epi32(_mm_add_epi32(v0, rounding), shift);
|
||||
const __m128i vr1 = _mm_srai_epi32(_mm_add_epi32(v1, rounding), shift);
|
||||
const __m128i e0 =
|
||||
_mm_sub_epi16(_mm_add_epi16(_mm_packs_epi32(vr0, vr1), d0), s0);
|
||||
const __m128i err0 = _mm_madd_epi16(e0, e0);
|
||||
sum32 = _mm_add_epi32(sum32, err0);
|
||||
}
|
||||
for (k = j; k < width; ++k) {
|
||||
const int32_t u = (int32_t)(dat[k] << SGRPROJ_RST_BITS);
|
||||
int32_t v = xq[1] * (flt1[k] - u);
|
||||
const int32_t e = ROUND_POWER_OF_TWO(v, shift) + dat[k] - src[k];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
flt1 += flt1_stride;
|
||||
const __m128i sum64_0 = _mm_cvtepi32_epi64(sum32);
|
||||
const __m128i sum64_1 = _mm_cvtepi32_epi64(_mm_srli_si128(sum32, 8));
|
||||
sum64 = _mm_add_epi64(sum64, sum64_0);
|
||||
sum64 = _mm_add_epi64(sum64, sum64_1);
|
||||
}
|
||||
} else {
|
||||
__m128i sum32 = _mm_setzero_si128();
|
||||
for (i = 0; i < height; ++i) {
|
||||
for (j = 0; j < width - 16; j += 16) {
|
||||
const __m128i d = xx_loadu_128(dat + j);
|
||||
const __m128i s = xx_loadu_128(src + j);
|
||||
const __m128i d0 = _mm_cvtepu8_epi16(d);
|
||||
const __m128i d1 = _mm_cvtepu8_epi16(_mm_srli_si128(d, 8));
|
||||
const __m128i s0 = _mm_cvtepu8_epi16(s);
|
||||
const __m128i s1 = _mm_cvtepu8_epi16(_mm_srli_si128(s, 8));
|
||||
const __m128i diff0 = _mm_sub_epi16(d0, s0);
|
||||
const __m128i diff1 = _mm_sub_epi16(d1, s1);
|
||||
const __m128i err0 = _mm_madd_epi16(diff0, diff0);
|
||||
const __m128i err1 = _mm_madd_epi16(diff1, diff1);
|
||||
sum32 = _mm_add_epi32(sum32, err0);
|
||||
sum32 = _mm_add_epi32(sum32, err1);
|
||||
}
|
||||
for (k = j; k < width; ++k) {
|
||||
const int32_t e = (int32_t)(dat[k]) - src[k];
|
||||
err += e * e;
|
||||
}
|
||||
dat += dat_stride;
|
||||
src += src_stride;
|
||||
}
|
||||
const __m128i sum64_0 = _mm_cvtepi32_epi64(sum32);
|
||||
const __m128i sum64_1 = _mm_cvtepi32_epi64(_mm_srli_si128(sum32, 8));
|
||||
sum64 = _mm_add_epi64(sum64_0, sum64_1);
|
||||
}
|
||||
int64_t sum[2];
|
||||
xx_storeu_128(sum, sum64);
|
||||
err += sum[0] + sum[1];
|
||||
return err;
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
#include <smmintrin.h>
|
||||
|
||||
#include "aom_dsp/x86/synonyms.h"
|
||||
|
||||
#include "aom_dsp/x86/synonyms_avx2.h"
|
||||
#include "aom/aom_integer.h"
|
||||
|
||||
#include "av1/common/reconinter.h"
|
||||
|
|
@ -31,7 +31,7 @@ uint64_t av1_wedge_sse_from_residuals_avx2(const int16_t *r1, const int16_t *d,
|
|||
uint64_t csse;
|
||||
|
||||
const __m256i v_mask_max_w = _mm256_set1_epi16(MAX_MASK_VALUE);
|
||||
const __m256i v_zext_q = _mm256_set1_epi64x(0xffffffff);
|
||||
const __m256i v_zext_q = yy_set1_64_from_32i(0xffffffff);
|
||||
|
||||
__m256i v_acc0_q = _mm256_setzero_si256();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue