Commit f0a4485e authored by Debargha Mukherjee's avatar Debargha Mukherjee

Refactor to separate restoration from loop filter

Change-Id: Iab517862d957f3aa2a664e9349d57bbf424febb3
parent af99a616
This diff is collapsed.
......@@ -15,6 +15,7 @@
#include "./vpx_config.h"
#include "vp10/common/blockd.h"
#include "vp10/common/restoration.h"
#include "vp10/common/seg_common.h"
#ifdef __cplusplus
......@@ -28,69 +29,6 @@ extern "C" {
#define MAX_MODE_LF_DELTAS 2
#if CONFIG_LOOP_RESTORATION
#define RESTORATION_LEVEL_BITS_KF 4
#define RESTORATION_LEVELS_KF (1 << RESTORATION_LEVEL_BITS_KF)
#define RESTORATION_LEVEL_BITS 3
#define RESTORATION_LEVELS (1 << RESTORATION_LEVEL_BITS)
#define DEF_RESTORATION_LEVEL 2
#define RESTORATION_PRECISION 16
#define RESTORATION_HALFWIN 3
#define RESTORATION_WIN (2 * RESTORATION_HALFWIN + 1)
typedef struct restoration_params {
int sigma_x; // spatial variance x
int sigma_y; // spatial variance y
int sigma_r; // range variance
} restoration_params_t;
static restoration_params_t
restoration_level_to_params_arr[RESTORATION_LEVELS + 1] = {
// Values are rounded to 1/16 th precision
{0, 0, 0}, // 0 - default
{8, 9, 30},
{9, 8, 30},
{9, 11, 32},
{11, 9, 32},
{14, 14, 32},
{18, 18, 36},
{24, 24, 40},
{32, 32, 40},
};
static restoration_params_t
restoration_level_to_params_arr_kf[RESTORATION_LEVELS_KF + 1] = {
// Values are rounded to 1/16 th precision
{0, 0, 0}, // 0 - default
{8, 8, 30},
{9, 9, 32},
{10, 10, 32},
{12, 12, 32},
{14, 14, 32},
{18, 18, 36},
{24, 24, 40},
{30, 30, 44},
{36, 36, 48},
{42, 42, 48},
{48, 48, 48},
{48, 48, 56},
{56, 56, 48},
{56, 56, 56},
{56, 56, 64},
{64, 64, 48},
};
int vp10_restoration_level_bits(const struct VP10Common *const cm);
int vp10_loop_restoration_used(int level, int kf);
static INLINE restoration_params_t vp10_restoration_level_to_params(
int index, int kf) {
return kf ? restoration_level_to_params_arr_kf[index] :
restoration_level_to_params_arr[index];
}
#endif // CONFIG_LOOP_RESTORATION
enum lf_path {
LF_PATH_420,
LF_PATH_444,
......@@ -132,14 +70,6 @@ typedef struct {
typedef struct {
loop_filter_thresh lfthr[MAX_LOOP_FILTER + 1];
uint8_t lvl[MAX_SEGMENTS][MAX_REF_FRAMES][MAX_MODE_LF_DELTAS];
#if CONFIG_LOOP_RESTORATION
double *wx_lut[RESTORATION_WIN];
double *wr_lut;
int restoration_sigma_x_set;
int restoration_sigma_y_set;
int restoration_sigma_r_set;
int restoration_used;
#endif // CONFIG_LOOP_RESTORATION
} loop_filter_info_n;
// This structure holds bit masks for all 8x8 blocks in a 64x64 region.
......@@ -209,24 +139,6 @@ void vp10_loop_filter_rows(YV12_BUFFER_CONFIG *frame_buffer,
struct macroblockd_plane planes[MAX_MB_PLANE],
int start, int stop, int y_only);
#if CONFIG_LOOP_RESTORATION
void vp10_loop_restoration_frame(YV12_BUFFER_CONFIG *frame,
struct VP10Common *cm,
int restoration_level,
int y_only, int partial_frame);
void vp10_loop_filter_restoration_frame(YV12_BUFFER_CONFIG *frame,
struct VP10Common *cm,
struct macroblockd *mbd,
int frame_filter_level,
int restoration_level,
int y_only, int partial_frame);
void vp10_loop_restoration_init(loop_filter_info_n *lfi, int T, int kf);
void vp10_loop_restoration_rows(YV12_BUFFER_CONFIG *frame,
struct VP10Common *cm,
int start_mi_row, int end_mi_row,
int y_only);
#endif // CONFIG_LOOP_RESTORATION
typedef struct LoopFilterWorkerData {
YV12_BUFFER_CONFIG *frame_buffer;
struct VP10Common *cm;
......
......@@ -24,6 +24,7 @@
#include "vp10/common/frame_buffers.h"
#include "vp10/common/quant_common.h"
#include "vp10/common/tile_common.h"
#include "vp10/common/restoration.h"
#if CONFIG_VP9_POSTPROC
#include "vp10/common/postproc.h"
......@@ -255,6 +256,9 @@ typedef struct VP10Common {
INTERP_FILTER interp_filter;
loop_filter_info_n lf_info;
#if CONFIG_LOOP_RESTORATION
restoration_info_n rst_info;
#endif // CONFIG_LOOP_RESTORATION
// Flag signaling how frame contexts should be updated at the end of
// a frame decode
......
This diff is collapsed.
/*
* Copyright (c) 2016 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VP10_COMMON_RESTORATION_H_
#define VP10_COMMON_RESTORATION_H_
#include "vpx_ports/mem.h"
#include "./vpx_config.h"
#include "vp10/common/blockd.h"
#ifdef __cplusplus
extern "C" {
#endif
#define RESTORATION_LEVEL_BITS_KF 4
#define RESTORATION_LEVELS_KF (1 << RESTORATION_LEVEL_BITS_KF)
#define RESTORATION_LEVEL_BITS 3
#define RESTORATION_LEVELS (1 << RESTORATION_LEVEL_BITS)
#define DEF_RESTORATION_LEVEL 2
#define RESTORATION_PRECISION 16
#define RESTORATION_HALFWIN 3
#define RESTORATION_WIN (2 * RESTORATION_HALFWIN + 1)
typedef struct restoration_params {
int sigma_x; // spatial variance x
int sigma_y; // spatial variance y
int sigma_r; // range variance
} restoration_params_t;
static restoration_params_t
restoration_level_to_params_arr[RESTORATION_LEVELS + 1] = {
// Values are rounded to 1/16 th precision
{0, 0, 0}, // 0 - default
{8, 9, 30},
{9, 8, 30},
{9, 11, 32},
{11, 9, 32},
{14, 14, 32},
{18, 18, 36},
{24, 24, 40},
{32, 32, 40},
};
static restoration_params_t
restoration_level_to_params_arr_kf[RESTORATION_LEVELS_KF + 1] = {
// Values are rounded to 1/16 th precision
{0, 0, 0}, // 0 - default
{8, 8, 30},
{9, 9, 32},
{10, 10, 32},
{12, 12, 32},
{14, 14, 32},
{18, 18, 36},
{24, 24, 40},
{30, 30, 44},
{36, 36, 48},
{42, 42, 48},
{48, 48, 48},
{48, 48, 56},
{56, 56, 48},
{56, 56, 56},
{56, 56, 64},
{64, 64, 48},
};
typedef struct {
double *wx_lut[RESTORATION_WIN];
double *wr_lut;
int restoration_sigma_x_set;
int restoration_sigma_y_set;
int restoration_sigma_r_set;
int restoration_used;
} restoration_info_n;
int vp10_restoration_level_bits(const struct VP10Common *const cm);
int vp10_loop_restoration_used(int level, int kf);
static INLINE restoration_params_t vp10_restoration_level_to_params(
int index, int kf) {
return kf ? restoration_level_to_params_arr_kf[index] :
restoration_level_to_params_arr[index];
}
void vp10_loop_restoration_init(restoration_info_n *rst, int T, int kf);
void vp10_loop_restoration_frame(YV12_BUFFER_CONFIG *frame,
struct VP10Common *cm,
int restoration_level,
int y_only, int partial_frame);
void vp10_loop_restoration_rows(YV12_BUFFER_CONFIG *frame,
struct VP10Common *cm,
int start_mi_row, int end_mi_row,
int y_only);
void vp10_loop_restoration_precal();
#ifdef __cplusplus
} // extern "C"
#endif
#endif // VP10_COMMON_RESTORATION_H_
......@@ -3481,9 +3481,9 @@ void vp10_decode_frame(VP10Decoder *pbi,
*p_data_end = decode_tiles(pbi, data + first_partition_size, data_end);
}
#if CONFIG_LOOP_RESTORATION
vp10_loop_restoration_init(&cm->lf_info, cm->lf.restoration_level,
vp10_loop_restoration_init(&cm->rst_info, cm->lf.restoration_level,
cm->frame_type == KEY_FRAME);
if (cm->lf_info.restoration_used) {
if (cm->rst_info.restoration_used) {
vp10_loop_restoration_rows(new_fb, cm, 0, cm->mi_rows, 0);
}
#endif // CONFIG_LOOP_RESTORATION
......
......@@ -115,6 +115,9 @@ VP10Decoder *vp10_decoder_create(BufferPool *const pool) {
cm->setup_mi = vp10_dec_setup_mi;
vp10_loop_filter_init(cm);
#if CONFIG_LOOP_RESTORATION
vp10_loop_restoration_precal();
#endif // CONFIG_LOOP_RESTORATION
#if CONFIG_ANS
vp10_build_pareto8_dec_tab(vp10_pareto8_token_probs, pbi->token_tab);
#endif // CONFIG_ANS
......
......@@ -1871,6 +1871,9 @@ VP10_COMP *vp10_create_compressor(VP10EncoderConfig *oxcf,
vp10_init_quantizer(cpi);
vp10_loop_filter_init(cm);
#if CONFIG_LOOP_RESTORATION
vp10_loop_restoration_precal();
#endif // CONFIG_LOOP_RESTORATION
cm->error.setjmp = 0;
......@@ -2779,9 +2782,9 @@ static void loopfilter_frame(VP10_COMP *cpi, VP10_COMMON *cm) {
#endif
}
#if CONFIG_LOOP_RESTORATION
vp10_loop_restoration_init(&cm->lf_info, cm->lf.restoration_level,
cm->frame_type == KEY_FRAME);
if (cm->lf_info.restoration_used)
vp10_loop_restoration_init(&cm->rst_info, cm->lf.restoration_level,
cm->frame_type == KEY_FRAME);
if (cm->rst_info.restoration_used)
vp10_loop_restoration_rows(cm->frame_to_show, cm, 0, cm->mi_rows, 0);
#endif // CONFIG_LOOP_RESTORATION
......
......@@ -80,6 +80,8 @@ VP10_COMMON_SRCS-$(CONFIG_ANS) += common/divide.c
VP10_COMMON_SRCS-$(CONFIG_VP9_POSTPROC) += common/postproc.h
VP10_COMMON_SRCS-$(CONFIG_VP9_POSTPROC) += common/postproc.c
VP10_COMMON_SRCS-$(CONFIG_LOOP_RESTORATION) += common/restoration.h
VP10_COMMON_SRCS-$(CONFIG_LOOP_RESTORATION) += common/restoration.c
VP10_COMMON_SRCS-$(CONFIG_VP9_POSTPROC) += common/mfqe.h
VP10_COMMON_SRCS-$(CONFIG_VP9_POSTPROC) += common/mfqe.c
ifeq ($(CONFIG_VP9_POSTPROC),yes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment