Moving all loop filter related variables into new struct.

Adding loopfilter struct with fields from MACROBLOCKD and VP9Common.
Eventually it will be moved to vp9_loopfilter.h for better code structure.

Change-Id: Iaf5fb71c33719cdfa1b991f671caf071be9ea035
This commit is contained in:
Dmitry Kovalev
2013-07-17 18:37:45 -07:00
parent f00a237a43
commit ee1771ebaa
14 changed files with 127 additions and 120 deletions

View File

@@ -31,9 +31,6 @@
#define MBSKIP_CONTEXTS 3 #define MBSKIP_CONTEXTS 3
#define MAX_REF_LF_DELTAS 4
#define MAX_MODE_LF_DELTAS 2
/* Segment Feature Masks */ /* Segment Feature Masks */
#define MAX_MV_REF_CANDIDATES 2 #define MAX_MV_REF_CANDIDATES 2
@@ -215,6 +212,27 @@ struct macroblockd_plane {
#define BLOCK_OFFSET(x, i, n) ((x) + (i) * (n)) #define BLOCK_OFFSET(x, i, n) ((x) + (i) * (n))
#define MAX_REF_LF_DELTAS 4
#define MAX_MODE_LF_DELTAS 2
struct loopfilter {
int filter_level;
int sharpness_level;
int last_sharpness_level;
uint8_t mode_ref_delta_enabled;
uint8_t mode_ref_delta_update;
// 0 = Intra, Last, GF, ARF
signed char ref_deltas[MAX_REF_LF_DELTAS];
signed char last_ref_deltas[MAX_REF_LF_DELTAS];
// 0 = ZERO_MV, MV
signed char mode_deltas[MAX_MODE_LF_DELTAS];
signed char last_mode_deltas[MAX_MODE_LF_DELTAS];
};
typedef struct macroblockd { typedef struct macroblockd {
struct macroblockd_plane plane[MAX_MB_PLANE]; struct macroblockd_plane plane[MAX_MB_PLANE];
@@ -231,26 +249,12 @@ typedef struct macroblockd {
int right_available; int right_available;
struct segmentation seg; struct segmentation seg;
struct loopfilter lf;
// partition contexts // partition contexts
PARTITION_CONTEXT *above_seg_context; PARTITION_CONTEXT *above_seg_context;
PARTITION_CONTEXT *left_seg_context; PARTITION_CONTEXT *left_seg_context;
/* mode_based Loop filter adjustment */
unsigned char mode_ref_lf_delta_enabled;
unsigned char mode_ref_lf_delta_update;
/* Delta values have the range +/- MAX_LOOP_FILTER */
/* 0 = Intra, Last, GF, ARF */
signed char last_ref_lf_deltas[MAX_REF_LF_DELTAS];
/* 0 = Intra, Last, GF, ARF */
signed char ref_lf_deltas[MAX_REF_LF_DELTAS];
/* 0 = ZERO_MV, MV */
signed char last_mode_lf_deltas[MAX_MODE_LF_DELTAS];
/* 0 = ZERO_MV, MV */
signed char mode_lf_deltas[MAX_MODE_LF_DELTAS];
/* Distance of MB away from frame edges */ /* Distance of MB away from frame edges */
int mb_to_left_edge; int mb_to_left_edge;
int mb_to_right_edge; int mb_to_right_edge;

View File

@@ -553,16 +553,16 @@ void vp9_adapt_mode_probs(VP9_COMMON *cm) {
} }
static void set_default_lf_deltas(MACROBLOCKD *xd) { static void set_default_lf_deltas(MACROBLOCKD *xd) {
xd->mode_ref_lf_delta_enabled = 1; xd->lf.mode_ref_delta_enabled = 1;
xd->mode_ref_lf_delta_update = 1; xd->lf.mode_ref_delta_update = 1;
xd->ref_lf_deltas[INTRA_FRAME] = 1; xd->lf.ref_deltas[INTRA_FRAME] = 1;
xd->ref_lf_deltas[LAST_FRAME] = 0; xd->lf.ref_deltas[LAST_FRAME] = 0;
xd->ref_lf_deltas[GOLDEN_FRAME] = -1; xd->lf.ref_deltas[GOLDEN_FRAME] = -1;
xd->ref_lf_deltas[ALTREF_FRAME] = -1; xd->lf.ref_deltas[ALTREF_FRAME] = -1;
xd->mode_lf_deltas[0] = 0; xd->lf.mode_deltas[0] = 0;
xd->mode_lf_deltas[1] = 0; xd->lf.mode_deltas[1] = 0;
} }
void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) { void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
@@ -575,8 +575,8 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vpx_memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols)); vpx_memset(cm->last_frame_seg_map, 0, (cm->mi_rows * cm->mi_cols));
// Reset the mode ref deltas for loop filter // Reset the mode ref deltas for loop filter
vp9_zero(xd->last_ref_lf_deltas); vp9_zero(xd->lf.last_ref_deltas);
vp9_zero(xd->last_mode_lf_deltas); vp9_zero(xd->lf.last_mode_deltas);
set_default_lf_deltas(xd); set_default_lf_deltas(xd);
vp9_default_coef_probs(cm); vp9_default_coef_probs(cm);
@@ -585,7 +585,7 @@ void vp9_setup_past_independence(VP9_COMMON *cm, MACROBLOCKD *xd) {
vp9_init_mv_probs(cm); vp9_init_mv_probs(cm);
// To force update of the sharpness // To force update of the sharpness
cm->last_sharpness_level = -1; xd->lf.last_sharpness_level = -1;
vp9_init_mode_contexts(cm); vp9_init_mode_contexts(cm);

View File

@@ -55,13 +55,13 @@ static void update_sharpness(loop_filter_info_n *const lfi, int sharpness_lvl) {
} }
} }
void vp9_loop_filter_init(VP9_COMMON *cm) { void vp9_loop_filter_init(VP9_COMMON *cm, struct loopfilter *lf) {
loop_filter_info_n *lfi = &cm->lf_info; loop_filter_info_n *lfi = &cm->lf_info;
int i; int i;
// init limits for given sharpness // init limits for given sharpness
update_sharpness(lfi, cm->sharpness_level); update_sharpness(lfi, lf->sharpness_level);
cm->last_sharpness_level = cm->sharpness_level; lf->last_sharpness_level = lf->sharpness_level;
// init LUT for lvl and hev thr picking // init LUT for lvl and hev thr picking
lf_init_lut(lfi); lf_init_lut(lfi);
@@ -79,11 +79,12 @@ static void loop_filter_frame_init(VP9_COMMON *const cm, MACROBLOCKD *const xd,
// 2 when filter_lvl is between 32 and 63 // 2 when filter_lvl is between 32 and 63
const int n_shift = default_filt_lvl >> 5; const int n_shift = default_filt_lvl >> 5;
loop_filter_info_n *const lfi = &cm->lf_info; loop_filter_info_n *const lfi = &cm->lf_info;
struct loopfilter *lf = &xd->lf;
// update limits if sharpness has changed // update limits if sharpness has changed
if (cm->last_sharpness_level != cm->sharpness_level) { if (lf->last_sharpness_level != lf->sharpness_level) {
update_sharpness(lfi, cm->sharpness_level); update_sharpness(lfi, lf->sharpness_level);
cm->last_sharpness_level = cm->sharpness_level; lf->last_sharpness_level = lf->sharpness_level;
} }
for (seg = 0; seg < MAX_MB_SEGMENTS; seg++) { for (seg = 0; seg < MAX_MB_SEGMENTS; seg++) {
@@ -97,20 +98,20 @@ static void loop_filter_frame_init(VP9_COMMON *const cm, MACROBLOCKD *const xd,
: clamp(default_filt_lvl + data, 0, MAX_LOOP_FILTER); : clamp(default_filt_lvl + data, 0, MAX_LOOP_FILTER);
} }
if (!xd->mode_ref_lf_delta_enabled) { if (!lf->mode_ref_delta_enabled) {
// we could get rid of this if we assume that deltas are set to // we could get rid of this if we assume that deltas are set to
// zero when not in use; encoder always uses deltas // zero when not in use; encoder always uses deltas
vpx_memset(lfi->lvl[seg][0], lvl_seg, 4 * 4); vpx_memset(lfi->lvl[seg][0], lvl_seg, 4 * 4);
continue; continue;
} }
intra_lvl = lvl_seg + (xd->ref_lf_deltas[INTRA_FRAME] << n_shift); intra_lvl = lvl_seg + (lf->ref_deltas[INTRA_FRAME] << n_shift);
lfi->lvl[seg][INTRA_FRAME][0] = clamp(intra_lvl, 0, MAX_LOOP_FILTER); lfi->lvl[seg][INTRA_FRAME][0] = clamp(intra_lvl, 0, MAX_LOOP_FILTER);
for (ref = LAST_FRAME; ref < MAX_REF_FRAMES; ++ref) for (ref = LAST_FRAME; ref < MAX_REF_FRAMES; ++ref)
for (mode = 0; mode < MAX_MODE_LF_DELTAS; ++mode) { for (mode = 0; mode < MAX_MODE_LF_DELTAS; ++mode) {
const int inter_lvl = lvl_seg + (xd->ref_lf_deltas[ref] << n_shift) const int inter_lvl = lvl_seg + (lf->ref_deltas[ref] << n_shift)
+ (xd->mode_lf_deltas[mode] << n_shift); + (lf->mode_deltas[mode] << n_shift);
lfi->lvl[seg][ref][mode] = clamp(inter_lvl, 0, MAX_LOOP_FILTER); lfi->lvl[seg][ref][mode] = clamp(inter_lvl, 0, MAX_LOOP_FILTER);
} }
} }

View File

@@ -46,7 +46,7 @@ struct loop_filter_info {
struct VP9Common; struct VP9Common;
struct macroblockd; struct macroblockd;
void vp9_loop_filter_init(struct VP9Common *cm); void vp9_loop_filter_init(struct VP9Common *cm, struct loopfilter *lf);
void vp9_loop_filter_frame(struct VP9Common *cm, void vp9_loop_filter_frame(struct VP9Common *cm,
struct macroblockd *mbd, struct macroblockd *mbd,

View File

@@ -202,10 +202,6 @@ typedef struct VP9Common {
loop_filter_info_n lf_info; loop_filter_info_n lf_info;
int filter_level;
int last_sharpness_level;
int sharpness_level;
int refresh_frame_context; /* Two state 0 = NO, 1 = YES */ int refresh_frame_context; /* Two state 0 = NO, 1 = YES */
int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */ int ref_frame_sign_bias[MAX_REF_FRAMES]; /* Two state 0, 1 */

View File

@@ -630,9 +630,11 @@ static void constrain_line(int x0, int *x1, int y0, int *y1,
} }
} }
int vp9_post_proc_frame(VP9_COMMON *oci, YV12_BUFFER_CONFIG *dest, int vp9_post_proc_frame(struct VP9Common *oci,
struct loopfilter *lf,
YV12_BUFFER_CONFIG *dest,
vp9_ppflags_t *ppflags) { vp9_ppflags_t *ppflags) {
int q = oci->filter_level * 10 / 6; int q = lf->filter_level * 10 / 6;
int flags = ppflags->post_proc_flag; int flags = ppflags->post_proc_flag;
int deblock_level = ppflags->deblocking_level; int deblock_level = ppflags->deblocking_level;
int noise_level = ppflags->noise_level; int noise_level = ppflags->noise_level;

View File

@@ -26,8 +26,8 @@ struct postproc_state {
#include "vp9/common/vp9_onyxc_int.h" #include "vp9/common/vp9_onyxc_int.h"
#include "vp9/common/vp9_ppflags.h" #include "vp9/common/vp9_ppflags.h"
int vp9_post_proc_frame(struct VP9Common *oci, YV12_BUFFER_CONFIG *dest, int vp9_post_proc_frame(struct VP9Common *oci, struct loopfilter *lf,
vp9_ppflags_t *flags); YV12_BUFFER_CONFIG *dest, vp9_ppflags_t *flags);
void vp9_denoise(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q); void vp9_denoise(const YV12_BUFFER_CONFIG *src, YV12_BUFFER_CONFIG *dst, int q);

View File

@@ -438,30 +438,29 @@ static void setup_segmentation(struct segmentation *seg,
} }
} }
static void setup_loopfilter(VP9D_COMP *pbi, struct vp9_read_bit_buffer *rb) { static void setup_loopfilter(struct loopfilter *lf,
VP9_COMMON *const cm = &pbi->common; struct vp9_read_bit_buffer *rb) {
MACROBLOCKD *const xd = &pbi->mb;
cm->filter_level = vp9_rb_read_literal(rb, 6); lf->filter_level = vp9_rb_read_literal(rb, 6);
cm->sharpness_level = vp9_rb_read_literal(rb, 3); lf->sharpness_level = vp9_rb_read_literal(rb, 3);
// Read in loop filter deltas applied at the MB level based on mode or ref // Read in loop filter deltas applied at the MB level based on mode or ref
// frame. // frame.
xd->mode_ref_lf_delta_update = 0; lf->mode_ref_delta_update = 0;
xd->mode_ref_lf_delta_enabled = vp9_rb_read_bit(rb); lf->mode_ref_delta_enabled = vp9_rb_read_bit(rb);
if (xd->mode_ref_lf_delta_enabled) { if (lf->mode_ref_delta_enabled) {
xd->mode_ref_lf_delta_update = vp9_rb_read_bit(rb); lf->mode_ref_delta_update = vp9_rb_read_bit(rb);
if (xd->mode_ref_lf_delta_update) { if (lf->mode_ref_delta_update) {
int i; int i;
for (i = 0; i < MAX_REF_LF_DELTAS; i++) for (i = 0; i < MAX_REF_LF_DELTAS; i++)
if (vp9_rb_read_bit(rb)) if (vp9_rb_read_bit(rb))
xd->ref_lf_deltas[i] = vp9_rb_read_signed_literal(rb, 6); lf->ref_deltas[i] = vp9_rb_read_signed_literal(rb, 6);
for (i = 0; i < MAX_MODE_LF_DELTAS; i++) for (i = 0; i < MAX_MODE_LF_DELTAS; i++)
if (vp9_rb_read_bit(rb)) if (vp9_rb_read_bit(rb))
xd->mode_lf_deltas[i] = vp9_rb_read_signed_literal(rb, 6); lf->mode_deltas[i] = vp9_rb_read_signed_literal(rb, 6);
} }
} }
} }
@@ -796,7 +795,7 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi,
int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)]; int frame_to_show = cm->ref_frame_map[vp9_rb_read_literal(rb, 3)];
ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->new_fb_idx, frame_to_show); ref_cnt_fb(cm->fb_idx_ref_cnt, &cm->new_fb_idx, frame_to_show);
pbi->refresh_frame_flags = 0; pbi->refresh_frame_flags = 0;
cm->filter_level = 0; xd->lf.filter_level = 0;
return 0; return 0;
} }
@@ -880,9 +879,9 @@ static size_t read_uncompressed_header(VP9D_COMP *pbi,
if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode || cm->intra_only) if (cm->frame_type == KEY_FRAME || cm->error_resilient_mode || cm->intra_only)
vp9_setup_past_independence(cm, xd); vp9_setup_past_independence(cm, xd);
setup_loopfilter(pbi, rb); setup_loopfilter(&xd->lf, rb);
setup_quantization(pbi, rb); setup_quantization(pbi, rb);
setup_segmentation(&pbi->mb.seg, rb); setup_segmentation(&xd->seg, rb);
setup_tile_info(cm, rb); setup_tile_info(cm, rb);

View File

@@ -136,7 +136,7 @@ VP9D_PTR vp9_create_decompressor(VP9D_CONFIG *oxcf) {
// vp9_init_dequantizer() for every frame. // vp9_init_dequantizer() for every frame.
vp9_init_dequantizer(&pbi->common); vp9_init_dequantizer(&pbi->common);
vp9_loop_filter_init(&pbi->common); vp9_loop_filter_init(&pbi->common, &pbi->mb.lf);
pbi->common.error.setjmp = 0; pbi->common.error.setjmp = 0;
pbi->decoded_key_frame = 0; pbi->decoded_key_frame = 0;
@@ -346,9 +346,9 @@ int vp9_receive_compressed_data(VP9D_PTR ptr,
cm->current_video_frame + 1000); cm->current_video_frame + 1000);
#endif #endif
if (cm->filter_level) { if (pbi->mb.lf.filter_level) {
/* Apply the loop filter if appropriate. */ /* Apply the loop filter if appropriate. */
vp9_loop_filter_frame(cm, &pbi->mb, cm->filter_level, 0); vp9_loop_filter_frame(cm, &pbi->mb, pbi->mb.lf.filter_level, 0);
} }
#if WRITE_RECON_BUFFER == 2 #if WRITE_RECON_BUFFER == 2
@@ -413,7 +413,7 @@ int vp9_get_raw_frame(VP9D_PTR ptr, YV12_BUFFER_CONFIG *sd,
*time_end_stamp = 0; *time_end_stamp = 0;
#if CONFIG_POSTPROC #if CONFIG_POSTPROC
ret = vp9_post_proc_frame(&pbi->common, sd, flags); ret = vp9_post_proc_frame(&pbi->common, &pbi->mb.lf, sd, flags);
#else #else
if (pbi->common.frame_to_show) { if (pbi->common.frame_to_show) {

View File

@@ -925,29 +925,29 @@ static void update_coef_probs(VP9_COMP* const cpi, vp9_writer* const bc) {
update_coef_probs_common(bc, cpi, TX_32X32); update_coef_probs_common(bc, cpi, TX_32X32);
} }
static void encode_loopfilter(VP9_COMMON *pc, MACROBLOCKD *xd, static void encode_loopfilter(struct loopfilter *lf,
struct vp9_write_bit_buffer *wb) { struct vp9_write_bit_buffer *wb) {
int i; int i;
// Encode the loop filter level and type // Encode the loop filter level and type
vp9_wb_write_literal(wb, pc->filter_level, 6); vp9_wb_write_literal(wb, lf->filter_level, 6);
vp9_wb_write_literal(wb, pc->sharpness_level, 3); vp9_wb_write_literal(wb, lf->sharpness_level, 3);
// Write out loop filter deltas applied at the MB level based on mode or // Write out loop filter deltas applied at the MB level based on mode or
// ref frame (if they are enabled). // ref frame (if they are enabled).
vp9_wb_write_bit(wb, xd->mode_ref_lf_delta_enabled); vp9_wb_write_bit(wb, lf->mode_ref_delta_enabled);
if (xd->mode_ref_lf_delta_enabled) { if (lf->mode_ref_delta_enabled) {
// Do the deltas need to be updated // Do the deltas need to be updated
vp9_wb_write_bit(wb, xd->mode_ref_lf_delta_update); vp9_wb_write_bit(wb, lf->mode_ref_delta_update);
if (xd->mode_ref_lf_delta_update) { if (lf->mode_ref_delta_update) {
// Send update // Send update
for (i = 0; i < MAX_REF_LF_DELTAS; i++) { for (i = 0; i < MAX_REF_LF_DELTAS; i++) {
const int delta = xd->ref_lf_deltas[i]; const int delta = lf->ref_deltas[i];
// Frame level data // Frame level data
if (delta != xd->last_ref_lf_deltas[i]) { if (delta != lf->last_ref_deltas[i]) {
xd->last_ref_lf_deltas[i] = delta; lf->last_ref_deltas[i] = delta;
vp9_wb_write_bit(wb, 1); vp9_wb_write_bit(wb, 1);
assert(delta != 0); assert(delta != 0);
@@ -960,9 +960,9 @@ static void encode_loopfilter(VP9_COMMON *pc, MACROBLOCKD *xd,
// Send update // Send update
for (i = 0; i < MAX_MODE_LF_DELTAS; i++) { for (i = 0; i < MAX_MODE_LF_DELTAS; i++) {
const int delta = xd->mode_lf_deltas[i]; const int delta = lf->mode_deltas[i];
if (delta != xd->last_mode_lf_deltas[i]) { if (delta != lf->last_mode_deltas[i]) {
xd->last_mode_lf_deltas[i] = delta; lf->last_mode_deltas[i] = delta;
vp9_wb_write_bit(wb, 1); vp9_wb_write_bit(wb, 1);
assert(delta != 0); assert(delta != 0);
@@ -1372,7 +1372,7 @@ static void write_uncompressed_header(VP9_COMP *cpi,
vp9_wb_write_literal(wb, cm->frame_context_idx, NUM_FRAME_CONTEXTS_LOG2); vp9_wb_write_literal(wb, cm->frame_context_idx, NUM_FRAME_CONTEXTS_LOG2);
encode_loopfilter(cm, xd, wb); encode_loopfilter(&xd->lf, wb);
encode_quantization(cm, wb); encode_quantization(cm, wb);
encode_segmentation(cpi, wb); encode_segmentation(cpi, wb);

View File

@@ -1953,7 +1953,7 @@ static void switch_lossless_mode(VP9_COMP *cpi, int lossless) {
cpi->mb.e_mbd.inv_txm4x4_1_add = vp9_short_iwalsh4x4_1_add; cpi->mb.e_mbd.inv_txm4x4_1_add = vp9_short_iwalsh4x4_1_add;
cpi->mb.e_mbd.inv_txm4x4_add = vp9_short_iwalsh4x4_add; cpi->mb.e_mbd.inv_txm4x4_add = vp9_short_iwalsh4x4_add;
cpi->mb.optimize = 0; cpi->mb.optimize = 0;
cpi->common.filter_level = 0; cpi->mb.e_mbd.lf.filter_level = 0;
cpi->zbin_mode_boost_enabled = 0; cpi->zbin_mode_boost_enabled = 0;
cpi->common.tx_mode = ONLY_4X4; cpi->common.tx_mode = ONLY_4X4;
} else { } else {

View File

@@ -243,6 +243,7 @@ void vp9_initialize_enc() {
static void setup_features(VP9_COMP *cpi) { static void setup_features(VP9_COMP *cpi) {
MACROBLOCKD *xd = &cpi->mb.e_mbd; MACROBLOCKD *xd = &cpi->mb.e_mbd;
struct loopfilter *lf = &xd->lf;
// Set up default state for MB feature flags // Set up default state for MB feature flags
xd->seg.enabled = 0; xd->seg.enabled = 0;
@@ -253,12 +254,12 @@ static void setup_features(VP9_COMP *cpi) {
vp9_clearall_segfeatures(&xd->seg); vp9_clearall_segfeatures(&xd->seg);
xd->mode_ref_lf_delta_enabled = 0; lf->mode_ref_delta_enabled = 0;
xd->mode_ref_lf_delta_update = 0; lf->mode_ref_delta_update = 0;
vpx_memset(xd->ref_lf_deltas, 0, sizeof(xd->ref_lf_deltas)); vp9_zero(lf->ref_deltas);
vpx_memset(xd->mode_lf_deltas, 0, sizeof(xd->mode_lf_deltas)); vp9_zero(lf->mode_deltas);
vpx_memset(xd->last_ref_lf_deltas, 0, sizeof(xd->ref_lf_deltas)); vp9_zero(lf->last_ref_deltas);
vpx_memset(xd->last_mode_lf_deltas, 0, sizeof(xd->mode_lf_deltas)); vp9_zero(lf->last_mode_deltas);
set_default_lf_deltas(cpi); set_default_lf_deltas(cpi);
} }
@@ -544,20 +545,22 @@ static void update_reference_segmentation_map(VP9_COMP *cpi) {
} }
static void set_default_lf_deltas(VP9_COMP *cpi) { static void set_default_lf_deltas(VP9_COMP *cpi) {
cpi->mb.e_mbd.mode_ref_lf_delta_enabled = 1; struct loopfilter *lf = &cpi->mb.e_mbd.lf;
cpi->mb.e_mbd.mode_ref_lf_delta_update = 1;
vpx_memset(cpi->mb.e_mbd.ref_lf_deltas, 0, sizeof(cpi->mb.e_mbd.ref_lf_deltas)); lf->mode_ref_delta_enabled = 1;
vpx_memset(cpi->mb.e_mbd.mode_lf_deltas, 0, sizeof(cpi->mb.e_mbd.mode_lf_deltas)); lf->mode_ref_delta_update = 1;
vp9_zero(lf->ref_deltas);
vp9_zero(lf->mode_deltas);
// Test of ref frame deltas // Test of ref frame deltas
cpi->mb.e_mbd.ref_lf_deltas[INTRA_FRAME] = 2; lf->ref_deltas[INTRA_FRAME] = 2;
cpi->mb.e_mbd.ref_lf_deltas[LAST_FRAME] = 0; lf->ref_deltas[LAST_FRAME] = 0;
cpi->mb.e_mbd.ref_lf_deltas[GOLDEN_FRAME] = -2; lf->ref_deltas[GOLDEN_FRAME] = -2;
cpi->mb.e_mbd.ref_lf_deltas[ALTREF_FRAME] = -2; lf->ref_deltas[ALTREF_FRAME] = -2;
cpi->mb.e_mbd.mode_lf_deltas[0] = 0; // Zero lf->mode_deltas[0] = 0; // Zero
cpi->mb.e_mbd.mode_lf_deltas[1] = 0; // New mv lf->mode_deltas[1] = 0; // New mv
} }
static void set_rd_speed_thresholds(VP9_COMP *cpi, int mode, int speed) { static void set_rd_speed_thresholds(VP9_COMP *cpi, int mode, int speed) {
@@ -1285,7 +1288,7 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
// VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs) // VP8 sharpness level mapping 0-7 (vs 0-10 in general VPx dialogs)
cpi->oxcf.Sharpness = MIN(7, cpi->oxcf.Sharpness); cpi->oxcf.Sharpness = MIN(7, cpi->oxcf.Sharpness);
cm->sharpness_level = cpi->oxcf.Sharpness; cpi->mb.e_mbd.lf.sharpness_level = cpi->oxcf.Sharpness;
if (cpi->initial_width) { if (cpi->initial_width) {
// Increasing the size of the frame beyond the first seen frame, or some // Increasing the size of the frame beyond the first seen frame, or some
@@ -1688,7 +1691,7 @@ VP9_PTR vp9_create_compressor(VP9_CONFIG *oxcf) {
*/ */
vp9_init_quantizer(cpi); vp9_init_quantizer(cpi);
vp9_loop_filter_init(cm); vp9_loop_filter_init(cm, &cpi->mb.e_mbd.lf);
cpi->common.error.setjmp = 0; cpi->common.error.setjmp = 0;
@@ -2408,8 +2411,9 @@ static void update_reference_frames(VP9_COMP * const cpi) {
} }
static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) { static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
if (cpi->mb.e_mbd.lossless) { MACROBLOCKD *xd = &cpi->mb.e_mbd;
cm->filter_level = 0; if (xd->lossless) {
xd->lf.filter_level = 0;
} else { } else {
struct vpx_usec_timer timer; struct vpx_usec_timer timer;
@@ -2423,14 +2427,13 @@ static void loopfilter_frame(VP9_COMP *cpi, VP9_COMMON *cm) {
cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer); cpi->time_pick_lpf += vpx_usec_timer_elapsed(&timer);
} }
if (cm->filter_level > 0) { if (xd->lf.filter_level > 0) {
vp9_set_alt_lf_level(cpi, cm->filter_level); vp9_set_alt_lf_level(cpi, xd->lf.filter_level);
vp9_loop_filter_frame(cm, &cpi->mb.e_mbd, cm->filter_level, 0); vp9_loop_filter_frame(cm, xd, xd->lf.filter_level, 0);
} }
vp9_extend_frame_inner_borders(cm->frame_to_show, vp9_extend_frame_inner_borders(cm->frame_to_show,
cm->subsampling_x, cm->subsampling_y); cm->subsampling_x, cm->subsampling_y);
} }
static void scale_references(VP9_COMP *cpi) { static void scale_references(VP9_COMP *cpi) {
@@ -2585,7 +2588,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
} }
// Set default state for segment based loop filter update flags // Set default state for segment based loop filter update flags
xd->mode_ref_lf_delta_update = 0; xd->lf.mode_ref_delta_update = 0;
// Set various flags etc to special state if it is a key frame // Set various flags etc to special state if it is a key frame
@@ -3438,7 +3441,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// Clear the one shot update flags for segmentation map and mode/ref loop filter deltas. // Clear the one shot update flags for segmentation map and mode/ref loop filter deltas.
xd->seg.update_map = 0; xd->seg.update_map = 0;
xd->seg.update_data = 0; xd->seg.update_data = 0;
xd->mode_ref_lf_delta_update = 0; xd->lf.mode_ref_delta_update = 0;
// keep track of the last coded dimensions // keep track of the last coded dimensions
cm->last_width = cm->width; cm->last_width = cm->width;
@@ -3547,7 +3550,7 @@ static int frame_is_reference(const VP9_COMP *cpi) {
cpi->refresh_golden_frame || cpi->refresh_golden_frame ||
cpi->refresh_alt_ref_frame || cpi->refresh_alt_ref_frame ||
cm->refresh_frame_context || cm->refresh_frame_context ||
mb->mode_ref_lf_delta_update || mb->lf.mode_ref_delta_update ||
mb->seg.update_map || mb->seg.update_map ||
mb->seg.update_data; mb->seg.update_data;
} }
@@ -3953,7 +3956,7 @@ int vp9_get_preview_raw_frame(VP9_PTR comp, YV12_BUFFER_CONFIG *dest,
else { else {
int ret; int ret;
#if CONFIG_POSTPROC #if CONFIG_POSTPROC
ret = vp9_post_proc_frame(&cpi->common, dest, flags); ret = vp9_post_proc_frame(&cpi->common, &cpi->mb.e_mbd.lf, dest, flags);
#else #else
if (cpi->common.frame_to_show) { if (cpi->common.frame_to_show) {

View File

@@ -127,6 +127,7 @@ void vp9_set_alt_lf_level(VP9_COMP *cpi, int filt_val) {
void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) { void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) {
VP9_COMMON *cm = &cpi->common; VP9_COMMON *cm = &cpi->common;
struct loopfilter *lf = &cpi->mb.e_mbd.lf;
int best_err = 0; int best_err = 0;
int filt_err = 0; int filt_err = 0;
@@ -135,7 +136,8 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) {
int filter_step; int filter_step;
int filt_high = 0; int filt_high = 0;
int filt_mid = cm->filter_level; // Start search at previous frame filter level // Start search at previous frame filter level
int filt_mid = lf->filter_level;
int filt_low = 0; int filt_low = 0;
int filt_best; int filt_best;
int filt_direction = 0; int filt_direction = 0;
@@ -146,12 +148,12 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) {
vp8_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf); vp8_yv12_copy_y(cm->frame_to_show, &cpi->last_frame_uf);
if (cm->frame_type == KEY_FRAME) if (cm->frame_type == KEY_FRAME)
cm->sharpness_level = 0; lf->sharpness_level = 0;
else else
cm->sharpness_level = cpi->oxcf.Sharpness; lf->sharpness_level = cpi->oxcf.Sharpness;
// Start the search at the previous frame filter level unless it is now out of range. // Start the search at the previous frame filter level unless it is now out of range.
filt_mid = cm->filter_level; filt_mid = lf->filter_level;
if (filt_mid < min_filter_level) if (filt_mid < min_filter_level)
filt_mid = min_filter_level; filt_mid = min_filter_level;
@@ -232,5 +234,5 @@ void vp9_pick_filter_level(YV12_BUFFER_CONFIG *sd, VP9_COMP *cpi) {
} }
} }
cm->filter_level = filt_best; lf->filter_level = filt_best;
} }

View File

@@ -137,8 +137,8 @@ void vp9_save_coding_context(VP9_COMP *cpi) {
vpx_memcpy(cpi->coding_context.last_frame_seg_map_copy, vpx_memcpy(cpi->coding_context.last_frame_seg_map_copy,
cm->last_frame_seg_map, (cm->mi_rows * cm->mi_cols)); cm->last_frame_seg_map, (cm->mi_rows * cm->mi_cols));
vp9_copy(cc->last_ref_lf_deltas, xd->last_ref_lf_deltas); vp9_copy(cc->last_ref_lf_deltas, xd->lf.last_ref_deltas);
vp9_copy(cc->last_mode_lf_deltas, xd->last_mode_lf_deltas); vp9_copy(cc->last_mode_lf_deltas, xd->lf.last_mode_deltas);
vp9_copy(cc->coef_probs, cm->fc.coef_probs); vp9_copy(cc->coef_probs, cm->fc.coef_probs);
vp9_copy(cc->switchable_interp_prob, cm->fc.switchable_interp_prob); vp9_copy(cc->switchable_interp_prob, cm->fc.switchable_interp_prob);
@@ -176,8 +176,8 @@ void vp9_restore_coding_context(VP9_COMP *cpi) {
cpi->coding_context.last_frame_seg_map_copy, cpi->coding_context.last_frame_seg_map_copy,
(cm->mi_rows * cm->mi_cols)); (cm->mi_rows * cm->mi_cols));
vp9_copy(xd->last_ref_lf_deltas, cc->last_ref_lf_deltas); vp9_copy(xd->lf.last_ref_deltas, cc->last_ref_lf_deltas);
vp9_copy(xd->last_mode_lf_deltas, cc->last_mode_lf_deltas); vp9_copy(xd->lf.last_mode_deltas, cc->last_mode_lf_deltas);
vp9_copy(cm->fc.coef_probs, cc->coef_probs); vp9_copy(cm->fc.coef_probs, cc->coef_probs);
vp9_copy(cm->fc.switchable_interp_prob, cc->switchable_interp_prob); vp9_copy(cm->fc.switchable_interp_prob, cc->switchable_interp_prob);