2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
#include "vpx_config.h"
|
2012-11-09 02:09:30 +01:00
|
|
|
#include "vp8_rtcd.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "loopfilter.h"
|
|
|
|
#include "onyxc_int.h"
|
2011-06-10 13:10:21 +02:00
|
|
|
#include "vpx_mem/vpx_mem.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
typedef unsigned char uc;
|
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
static void lf_init_lut(loop_filter_info_n *lfi)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
int filt_lvl;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
for (filt_lvl = 0; filt_lvl <= MAX_LOOP_FILTER; filt_lvl++)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
if (filt_lvl >= 40)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 2;
|
|
|
|
lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 3;
|
|
|
|
}
|
|
|
|
else if (filt_lvl >= 20)
|
|
|
|
{
|
|
|
|
lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 1;
|
|
|
|
lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 2;
|
|
|
|
}
|
|
|
|
else if (filt_lvl >= 15)
|
|
|
|
{
|
|
|
|
lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 1;
|
|
|
|
lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 1;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
lfi->hev_thr_lut[KEY_FRAME][filt_lvl] = 0;
|
|
|
|
lfi->hev_thr_lut[INTER_FRAME][filt_lvl] = 0;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2011-06-10 13:10:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
lfi->mode_lf_lut[DC_PRED] = 1;
|
|
|
|
lfi->mode_lf_lut[V_PRED] = 1;
|
|
|
|
lfi->mode_lf_lut[H_PRED] = 1;
|
|
|
|
lfi->mode_lf_lut[TM_PRED] = 1;
|
|
|
|
lfi->mode_lf_lut[B_PRED] = 0;
|
|
|
|
|
|
|
|
lfi->mode_lf_lut[ZEROMV] = 1;
|
|
|
|
lfi->mode_lf_lut[NEARESTMV] = 2;
|
|
|
|
lfi->mode_lf_lut[NEARMV] = 2;
|
|
|
|
lfi->mode_lf_lut[NEWMV] = 2;
|
|
|
|
lfi->mode_lf_lut[SPLITMV] = 3;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_loop_filter_update_sharpness(loop_filter_info_n *lfi,
|
|
|
|
int sharpness_lvl)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* For each possible value for the loop filter fill out limits */
|
|
|
|
for (i = 0; i <= MAX_LOOP_FILTER; i++)
|
|
|
|
{
|
|
|
|
int filt_lvl = i;
|
|
|
|
int block_inside_limit = 0;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Set loop filter paramaeters that control sharpness. */
|
2010-05-18 17:58:33 +02:00
|
|
|
block_inside_limit = filt_lvl >> (sharpness_lvl > 0);
|
|
|
|
block_inside_limit = block_inside_limit >> (sharpness_lvl > 4);
|
|
|
|
|
|
|
|
if (sharpness_lvl > 0)
|
|
|
|
{
|
|
|
|
if (block_inside_limit > (9 - sharpness_lvl))
|
|
|
|
block_inside_limit = (9 - sharpness_lvl);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (block_inside_limit < 1)
|
|
|
|
block_inside_limit = 1;
|
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
vpx_memset(lfi->lim[i], block_inside_limit, SIMD_WIDTH);
|
|
|
|
vpx_memset(lfi->blim[i], (2 * filt_lvl + block_inside_limit),
|
|
|
|
SIMD_WIDTH);
|
|
|
|
vpx_memset(lfi->mblim[i], (2 * (filt_lvl + 2) + block_inside_limit),
|
|
|
|
SIMD_WIDTH);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
2011-06-10 13:10:21 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
void vp8_loop_filter_init(VP8_COMMON *cm)
|
|
|
|
{
|
|
|
|
loop_filter_info_n *lfi = &cm->lf_info;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* init limits for given sharpness*/
|
|
|
|
vp8_loop_filter_update_sharpness(lfi, cm->sharpness_level);
|
|
|
|
cm->last_sharpness_level = cm->sharpness_level;
|
|
|
|
|
|
|
|
/* init LUT for lvl and hev thr picking */
|
|
|
|
lf_init_lut(lfi);
|
|
|
|
|
|
|
|
/* init hev threshold const vectors */
|
|
|
|
for(i = 0; i < 4 ; i++)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
vpx_memset(lfi->hev_thr[i], i, SIMD_WIDTH);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
void vp8_loop_filter_frame_init(VP8_COMMON *cm,
|
|
|
|
MACROBLOCKD *mbd,
|
2011-07-20 21:53:42 +02:00
|
|
|
int default_filt_lvl)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
int seg, /* segment number */
|
|
|
|
ref, /* index in ref_lf_deltas */
|
|
|
|
mode; /* index in mode_lf_deltas */
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
loop_filter_info_n *lfi = &cm->lf_info;
|
|
|
|
|
|
|
|
/* update limits if sharpness has changed */
|
2011-07-20 21:53:42 +02:00
|
|
|
if(cm->last_sharpness_level != cm->sharpness_level)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-07-20 21:53:42 +02:00
|
|
|
vp8_loop_filter_update_sharpness(lfi, cm->sharpness_level);
|
|
|
|
cm->last_sharpness_level = cm->sharpness_level;
|
2011-06-10 13:10:21 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
for(seg = 0; seg < MAX_MB_SEGMENTS; seg++)
|
|
|
|
{
|
|
|
|
int lvl_seg = default_filt_lvl;
|
|
|
|
int lvl_ref, lvl_mode;
|
|
|
|
|
|
|
|
/* Note the baseline filter values for each segment */
|
|
|
|
if (mbd->segmentation_enabled)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
/* Abs value */
|
|
|
|
if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA)
|
|
|
|
{
|
|
|
|
lvl_seg = mbd->segment_feature_data[MB_LVL_ALT_LF][seg];
|
|
|
|
}
|
|
|
|
else /* Delta Value */
|
|
|
|
{
|
|
|
|
lvl_seg += mbd->segment_feature_data[MB_LVL_ALT_LF][seg];
|
|
|
|
lvl_seg = (lvl_seg > 0) ? ((lvl_seg > 63) ? 63: lvl_seg) : 0;
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
if (!mbd->mode_ref_lf_delta_enabled)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
/* we could get rid of this if we assume that deltas are set to
|
|
|
|
* zero when not in use; encoder always uses deltas
|
|
|
|
*/
|
|
|
|
vpx_memset(lfi->lvl[seg][0], lvl_seg, 4 * 4 );
|
|
|
|
continue;
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
lvl_ref = lvl_seg;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
/* INTRA_FRAME */
|
|
|
|
ref = INTRA_FRAME;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Apply delta for reference frame */
|
2011-06-10 13:10:21 +02:00
|
|
|
lvl_ref += mbd->ref_lf_deltas[ref];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
/* Apply delta for Intra modes */
|
|
|
|
mode = 0; /* B_PRED */
|
|
|
|
/* Only the split mode BPRED has a further special case */
|
|
|
|
lvl_mode = lvl_ref + mbd->mode_lf_deltas[mode];
|
|
|
|
lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
|
|
|
|
|
|
|
|
lfi->lvl[seg][ref][mode] = lvl_mode;
|
|
|
|
|
|
|
|
mode = 1; /* all the rest of Intra modes */
|
|
|
|
lvl_mode = (lvl_ref > 0) ? (lvl_ref > 63 ? 63 : lvl_ref) : 0; /* clamp */
|
|
|
|
lfi->lvl[seg][ref][mode] = lvl_mode;
|
|
|
|
|
|
|
|
/* LAST, GOLDEN, ALT */
|
|
|
|
for(ref = 1; ref < MAX_REF_FRAMES; ref++)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
int lvl_ref = lvl_seg;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
/* Apply delta for reference frame */
|
|
|
|
lvl_ref += mbd->ref_lf_deltas[ref];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
/* Apply delta for Inter modes */
|
|
|
|
for (mode = 1; mode < 4; mode++)
|
|
|
|
{
|
|
|
|
lvl_mode = lvl_ref + mbd->mode_lf_deltas[mode];
|
|
|
|
lvl_mode = (lvl_mode > 0) ? (lvl_mode > 63 ? 63 : lvl_mode) : 0; /* clamp */
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
lfi->lvl[seg][ref][mode] = lvl_mode;
|
|
|
|
}
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-02 20:58:09 +02:00
|
|
|
|
|
|
|
void vp8_loop_filter_row_normal(VP8_COMMON *cm, MODE_INFO *mode_info_context,
|
|
|
|
int mb_row, int post_ystride, int post_uvstride,
|
|
|
|
unsigned char *y_ptr, unsigned char *u_ptr,
|
|
|
|
unsigned char *v_ptr)
|
|
|
|
{
|
|
|
|
int mb_col;
|
|
|
|
int filter_level;
|
|
|
|
loop_filter_info_n *lfi_n = &cm->lf_info;
|
|
|
|
loop_filter_info lfi;
|
|
|
|
FRAME_TYPE frame_type = cm->frame_type;
|
|
|
|
|
|
|
|
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
|
|
|
|
{
|
|
|
|
int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
|
|
|
|
mode_info_context->mbmi.mode != SPLITMV &&
|
|
|
|
mode_info_context->mbmi.mb_skip_coeff);
|
|
|
|
|
|
|
|
const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
|
|
|
|
const int seg = mode_info_context->mbmi.segment_id;
|
|
|
|
const int ref_frame = mode_info_context->mbmi.ref_frame;
|
|
|
|
|
|
|
|
filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
|
|
|
|
|
|
|
|
if (filter_level)
|
|
|
|
{
|
|
|
|
const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
|
|
|
|
lfi.mblim = lfi_n->mblim[filter_level];
|
|
|
|
lfi.blim = lfi_n->blim[filter_level];
|
|
|
|
lfi.lim = lfi_n->lim[filter_level];
|
|
|
|
lfi.hev_thr = lfi_n->hev_thr[hev_index];
|
|
|
|
|
|
|
|
if (mb_col > 0)
|
|
|
|
vp8_loop_filter_mbv
|
|
|
|
(y_ptr, u_ptr, v_ptr, post_ystride, post_uvstride, &lfi);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
|
|
|
vp8_loop_filter_bv
|
|
|
|
(y_ptr, u_ptr, v_ptr, post_ystride, post_uvstride, &lfi);
|
|
|
|
|
|
|
|
/* don't apply across umv border */
|
|
|
|
if (mb_row > 0)
|
|
|
|
vp8_loop_filter_mbh
|
|
|
|
(y_ptr, u_ptr, v_ptr, post_ystride, post_uvstride, &lfi);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
|
|
|
vp8_loop_filter_bh
|
|
|
|
(y_ptr, u_ptr, v_ptr, post_ystride, post_uvstride, &lfi);
|
|
|
|
}
|
|
|
|
|
|
|
|
y_ptr += 16;
|
|
|
|
u_ptr += 8;
|
|
|
|
v_ptr += 8;
|
|
|
|
|
|
|
|
mode_info_context++; /* step to next MB */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_loop_filter_row_simple(VP8_COMMON *cm, MODE_INFO *mode_info_context,
|
|
|
|
int mb_row, int post_ystride, int post_uvstride,
|
|
|
|
unsigned char *y_ptr, unsigned char *u_ptr,
|
|
|
|
unsigned char *v_ptr)
|
|
|
|
{
|
|
|
|
int mb_col;
|
|
|
|
int filter_level;
|
|
|
|
loop_filter_info_n *lfi_n = &cm->lf_info;
|
|
|
|
|
|
|
|
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
|
|
|
|
{
|
|
|
|
int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
|
|
|
|
mode_info_context->mbmi.mode != SPLITMV &&
|
|
|
|
mode_info_context->mbmi.mb_skip_coeff);
|
|
|
|
|
|
|
|
const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
|
|
|
|
const int seg = mode_info_context->mbmi.segment_id;
|
|
|
|
const int ref_frame = mode_info_context->mbmi.ref_frame;
|
|
|
|
|
|
|
|
filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
|
|
|
|
|
|
|
|
if (filter_level)
|
|
|
|
{
|
|
|
|
if (mb_col > 0)
|
|
|
|
vp8_loop_filter_simple_mbv
|
|
|
|
(y_ptr, post_ystride, lfi_n->mblim[filter_level]);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
|
|
|
vp8_loop_filter_simple_bv
|
|
|
|
(y_ptr, post_ystride, lfi_n->blim[filter_level]);
|
|
|
|
|
|
|
|
/* don't apply across umv border */
|
|
|
|
if (mb_row > 0)
|
|
|
|
vp8_loop_filter_simple_mbh
|
|
|
|
(y_ptr, post_ystride, lfi_n->mblim[filter_level]);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
|
|
|
vp8_loop_filter_simple_bh
|
|
|
|
(y_ptr, post_ystride, lfi_n->blim[filter_level]);
|
|
|
|
}
|
|
|
|
|
|
|
|
y_ptr += 16;
|
|
|
|
u_ptr += 8;
|
|
|
|
v_ptr += 8;
|
|
|
|
|
|
|
|
mode_info_context++; /* step to next MB */
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-05-22 13:19:10 +02:00
|
|
|
void vp8_loop_filter_frame(VP8_COMMON *cm,
|
|
|
|
MACROBLOCKD *mbd,
|
|
|
|
int frame_type)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
YV12_BUFFER_CONFIG *post = cm->frame_to_show;
|
2011-06-10 13:10:21 +02:00
|
|
|
loop_filter_info_n *lfi_n = &cm->lf_info;
|
|
|
|
loop_filter_info lfi;
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
int mb_row;
|
|
|
|
int mb_col;
|
2012-04-12 20:22:47 +02:00
|
|
|
int mb_rows = cm->mb_rows;
|
|
|
|
int mb_cols = cm->mb_cols;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
int filter_level;
|
|
|
|
|
|
|
|
unsigned char *y_ptr, *u_ptr, *v_ptr;
|
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
/* Point at base of Mb MODE_INFO list */
|
|
|
|
const MODE_INFO *mode_info_context = cm->mi;
|
2012-04-12 20:22:47 +02:00
|
|
|
int post_y_stride = post->y_stride;
|
|
|
|
int post_uv_stride = post->uv_stride;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Initialize the loop filter for this frame. */
|
2011-07-20 21:53:42 +02:00
|
|
|
vp8_loop_filter_frame_init(cm, mbd, cm->filter_level);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Set up the buffer pointers */
|
2010-05-18 17:58:33 +02:00
|
|
|
y_ptr = post->y_buffer;
|
|
|
|
u_ptr = post->u_buffer;
|
|
|
|
v_ptr = post->v_buffer;
|
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* vp8_filter each macro block */
|
2012-04-12 20:22:47 +02:00
|
|
|
if (cm->filter_type == NORMAL_LOOPFILTER)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2012-04-12 20:22:47 +02:00
|
|
|
for (mb_row = 0; mb_row < mb_rows; mb_row++)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
2012-04-12 20:22:47 +02:00
|
|
|
for (mb_col = 0; mb_col < mb_cols; mb_col++)
|
|
|
|
{
|
|
|
|
int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
|
|
|
|
mode_info_context->mbmi.mode != SPLITMV &&
|
|
|
|
mode_info_context->mbmi.mb_skip_coeff);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-04-12 20:22:47 +02:00
|
|
|
const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
|
|
|
|
const int seg = mode_info_context->mbmi.segment_id;
|
|
|
|
const int ref_frame = mode_info_context->mbmi.ref_frame;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-04-12 20:22:47 +02:00
|
|
|
filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-04-12 20:22:47 +02:00
|
|
|
if (filter_level)
|
2011-06-10 13:10:21 +02:00
|
|
|
{
|
|
|
|
const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
|
|
|
|
lfi.mblim = lfi_n->mblim[filter_level];
|
|
|
|
lfi.blim = lfi_n->blim[filter_level];
|
|
|
|
lfi.lim = lfi_n->lim[filter_level];
|
|
|
|
lfi.hev_thr = lfi_n->hev_thr[hev_index];
|
|
|
|
|
|
|
|
if (mb_col > 0)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_mbv
|
2012-04-12 20:22:47 +02:00
|
|
|
(y_ptr, u_ptr, v_ptr, post_y_stride, post_uv_stride, &lfi);
|
2011-06-10 13:10:21 +02:00
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_bv
|
2012-04-12 20:22:47 +02:00
|
|
|
(y_ptr, u_ptr, v_ptr, post_y_stride, post_uv_stride, &lfi);
|
2011-06-10 13:10:21 +02:00
|
|
|
|
|
|
|
/* don't apply across umv border */
|
|
|
|
if (mb_row > 0)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_mbh
|
2012-04-12 20:22:47 +02:00
|
|
|
(y_ptr, u_ptr, v_ptr, post_y_stride, post_uv_stride, &lfi);
|
2011-06-10 13:10:21 +02:00
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_bh
|
2012-04-12 20:22:47 +02:00
|
|
|
(y_ptr, u_ptr, v_ptr, post_y_stride, post_uv_stride, &lfi);
|
2011-06-10 13:10:21 +02:00
|
|
|
}
|
2012-04-12 20:22:47 +02:00
|
|
|
|
|
|
|
y_ptr += 16;
|
|
|
|
u_ptr += 8;
|
|
|
|
v_ptr += 8;
|
|
|
|
|
|
|
|
mode_info_context++; /* step to next MB */
|
|
|
|
}
|
|
|
|
y_ptr += post_y_stride * 16 - post->y_width;
|
|
|
|
u_ptr += post_uv_stride * 8 - post->uv_width;
|
|
|
|
v_ptr += post_uv_stride * 8 - post->uv_width;
|
|
|
|
|
|
|
|
mode_info_context++; /* Skip border mb */
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else /* SIMPLE_LOOPFILTER */
|
|
|
|
{
|
|
|
|
for (mb_row = 0; mb_row < mb_rows; mb_row++)
|
|
|
|
{
|
|
|
|
for (mb_col = 0; mb_col < mb_cols; mb_col++)
|
|
|
|
{
|
|
|
|
int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
|
|
|
|
mode_info_context->mbmi.mode != SPLITMV &&
|
|
|
|
mode_info_context->mbmi.mb_skip_coeff);
|
|
|
|
|
|
|
|
const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
|
|
|
|
const int seg = mode_info_context->mbmi.segment_id;
|
|
|
|
const int ref_frame = mode_info_context->mbmi.ref_frame;
|
|
|
|
|
|
|
|
filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
|
|
|
|
if (filter_level)
|
2011-06-10 13:10:21 +02:00
|
|
|
{
|
2012-04-12 20:22:47 +02:00
|
|
|
const unsigned char * mblim = lfi_n->mblim[filter_level];
|
|
|
|
const unsigned char * blim = lfi_n->blim[filter_level];
|
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
if (mb_col > 0)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_mbv
|
2012-04-12 20:22:47 +02:00
|
|
|
(y_ptr, post_y_stride, mblim);
|
2011-06-10 13:10:21 +02:00
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_bv
|
2012-04-12 20:22:47 +02:00
|
|
|
(y_ptr, post_y_stride, blim);
|
2011-06-10 13:10:21 +02:00
|
|
|
|
|
|
|
/* don't apply across umv border */
|
|
|
|
if (mb_row > 0)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_mbh
|
2012-04-12 20:22:47 +02:00
|
|
|
(y_ptr, post_y_stride, mblim);
|
2011-06-10 13:10:21 +02:00
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_bh
|
2012-04-12 20:22:47 +02:00
|
|
|
(y_ptr, post_y_stride, blim);
|
2011-06-10 13:10:21 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-04-12 20:22:47 +02:00
|
|
|
y_ptr += 16;
|
|
|
|
u_ptr += 8;
|
|
|
|
v_ptr += 8;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-04-12 20:22:47 +02:00
|
|
|
mode_info_context++; /* step to next MB */
|
|
|
|
}
|
|
|
|
y_ptr += post_y_stride * 16 - post->y_width;
|
|
|
|
u_ptr += post_uv_stride * 8 - post->uv_width;
|
|
|
|
v_ptr += post_uv_stride * 8 - post->uv_width;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-04-12 20:22:47 +02:00
|
|
|
mode_info_context++; /* Skip border mb */
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2012-04-12 20:22:47 +02:00
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_loop_filter_frame_yonly
|
|
|
|
(
|
|
|
|
VP8_COMMON *cm,
|
|
|
|
MACROBLOCKD *mbd,
|
2011-07-20 21:53:42 +02:00
|
|
|
int default_filt_lvl
|
2010-05-18 17:58:33 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
YV12_BUFFER_CONFIG *post = cm->frame_to_show;
|
|
|
|
|
|
|
|
unsigned char *y_ptr;
|
|
|
|
int mb_row;
|
|
|
|
int mb_col;
|
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
loop_filter_info_n *lfi_n = &cm->lf_info;
|
|
|
|
loop_filter_info lfi;
|
|
|
|
|
2010-05-18 17:58:33 +02:00
|
|
|
int filter_level;
|
2010-10-28 01:04:02 +02:00
|
|
|
FRAME_TYPE frame_type = cm->frame_type;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
/* Point at base of Mb MODE_INFO list */
|
|
|
|
const MODE_INFO *mode_info_context = cm->mi;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
#if 0
|
|
|
|
if(default_filt_lvl == 0) /* no filter applied */
|
|
|
|
return;
|
|
|
|
#endif
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Initialize the loop filter for this frame. */
|
2011-07-20 21:53:42 +02:00
|
|
|
vp8_loop_filter_frame_init( cm, mbd, default_filt_lvl);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* Set up the buffer pointers */
|
2010-05-18 17:58:33 +02:00
|
|
|
y_ptr = post->y_buffer;
|
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* vp8_filter each macro block */
|
2010-05-18 17:58:33 +02:00
|
|
|
for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
|
|
|
|
{
|
|
|
|
for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
|
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
|
|
|
|
mode_info_context->mbmi.mode != SPLITMV &&
|
|
|
|
mode_info_context->mbmi.mb_skip_coeff);
|
2011-04-21 20:38:36 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
const int mode_index = lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
|
|
|
|
const int seg = mode_info_context->mbmi.segment_id;
|
|
|
|
const int ref_frame = mode_info_context->mbmi.ref_frame;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
if (filter_level)
|
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
if (cm->filter_type == NORMAL_LOOPFILTER)
|
|
|
|
{
|
|
|
|
const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
|
|
|
|
lfi.mblim = lfi_n->mblim[filter_level];
|
|
|
|
lfi.blim = lfi_n->blim[filter_level];
|
|
|
|
lfi.lim = lfi_n->lim[filter_level];
|
|
|
|
lfi.hev_thr = lfi_n->hev_thr[hev_index];
|
|
|
|
|
|
|
|
if (mb_col > 0)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_mbv
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, 0, 0, post->y_stride, 0, &lfi);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_bv
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, 0, 0, post->y_stride, 0, &lfi);
|
|
|
|
|
|
|
|
/* don't apply across umv border */
|
|
|
|
if (mb_row > 0)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_mbh
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, 0, 0, post->y_stride, 0, &lfi);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_bh
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, 0, 0, post->y_stride, 0, &lfi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (mb_col > 0)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_mbv
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_bv
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, post->y_stride, lfi_n->blim[filter_level]);
|
|
|
|
|
|
|
|
/* don't apply across umv border */
|
|
|
|
if (mb_row > 0)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_mbh
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_bh
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, post->y_stride, lfi_n->blim[filter_level]);
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
y_ptr += 16;
|
2011-06-10 13:10:21 +02:00
|
|
|
mode_info_context ++; /* step to next MB */
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
y_ptr += post->y_stride * 16 - post->y_width;
|
2011-06-10 13:10:21 +02:00
|
|
|
mode_info_context ++; /* Skip border mb */
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_loop_filter_partial_frame
|
|
|
|
(
|
|
|
|
VP8_COMMON *cm,
|
|
|
|
MACROBLOCKD *mbd,
|
2011-07-20 21:53:42 +02:00
|
|
|
int default_filt_lvl
|
2010-05-18 17:58:33 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
YV12_BUFFER_CONFIG *post = cm->frame_to_show;
|
|
|
|
|
|
|
|
unsigned char *y_ptr;
|
|
|
|
int mb_row;
|
|
|
|
int mb_col;
|
2011-10-18 08:48:50 +02:00
|
|
|
int mb_cols = post->y_width >> 4;
|
|
|
|
int mb_rows = post->y_height >> 4;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2013-01-04 00:47:34 +01:00
|
|
|
int linestocopy;
|
2011-06-10 13:10:21 +02:00
|
|
|
|
|
|
|
loop_filter_info_n *lfi_n = &cm->lf_info;
|
|
|
|
loop_filter_info lfi;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
int filter_level;
|
2010-10-28 01:04:02 +02:00
|
|
|
FRAME_TYPE frame_type = cm->frame_type;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-06-10 13:10:21 +02:00
|
|
|
const MODE_INFO *mode_info_context;
|
|
|
|
|
2013-01-04 00:47:34 +01:00
|
|
|
#if 0
|
|
|
|
if(default_filt_lvl == 0) /* no filter applied */
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Initialize the loop filter for this frame. */
|
|
|
|
vp8_loop_filter_frame_init( cm, mbd, default_filt_lvl);
|
2011-06-10 13:10:21 +02:00
|
|
|
|
2011-10-18 08:48:50 +02:00
|
|
|
/* number of MB rows to use in partial filtering */
|
|
|
|
linestocopy = mb_rows / PARTIAL_FRAME_FRACTION;
|
|
|
|
linestocopy = linestocopy ? linestocopy << 4 : 16; /* 16 lines per MB */
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-10-18 08:48:50 +02:00
|
|
|
/* Set up the buffer pointers; partial image starts at ~middle of frame */
|
|
|
|
y_ptr = post->y_buffer + ((post->y_height >> 5) * 16) * post->y_stride;
|
|
|
|
mode_info_context = cm->mi + (post->y_height >> 5) * (mb_cols + 1);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-10-28 01:04:02 +02:00
|
|
|
/* vp8_filter each macro block */
|
2010-05-18 17:58:33 +02:00
|
|
|
for (mb_row = 0; mb_row<(linestocopy >> 4); mb_row++)
|
|
|
|
{
|
|
|
|
for (mb_col = 0; mb_col < mb_cols; mb_col++)
|
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
int skip_lf = (mode_info_context->mbmi.mode != B_PRED &&
|
|
|
|
mode_info_context->mbmi.mode != SPLITMV &&
|
|
|
|
mode_info_context->mbmi.mb_skip_coeff);
|
2011-04-21 20:38:36 +02:00
|
|
|
|
2013-01-04 00:47:34 +01:00
|
|
|
const int mode_index =
|
|
|
|
lfi_n->mode_lf_lut[mode_info_context->mbmi.mode];
|
|
|
|
const int seg = mode_info_context->mbmi.segment_id;
|
|
|
|
const int ref_frame = mode_info_context->mbmi.ref_frame;
|
|
|
|
|
|
|
|
filter_level = lfi_n->lvl[seg][ref_frame][mode_index];
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
if (filter_level)
|
|
|
|
{
|
2011-06-10 13:10:21 +02:00
|
|
|
if (cm->filter_type == NORMAL_LOOPFILTER)
|
|
|
|
{
|
|
|
|
const int hev_index = lfi_n->hev_thr_lut[frame_type][filter_level];
|
|
|
|
lfi.mblim = lfi_n->mblim[filter_level];
|
|
|
|
lfi.blim = lfi_n->blim[filter_level];
|
|
|
|
lfi.lim = lfi_n->lim[filter_level];
|
|
|
|
lfi.hev_thr = lfi_n->hev_thr[hev_index];
|
|
|
|
|
|
|
|
if (mb_col > 0)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_mbv
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, 0, 0, post->y_stride, 0, &lfi);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_bv
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, 0, 0, post->y_stride, 0, &lfi);
|
|
|
|
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_mbh
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, 0, 0, post->y_stride, 0, &lfi);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_bh
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, 0, 0, post->y_stride, 0, &lfi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (mb_col > 0)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_mbv
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_bv
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, post->y_stride, lfi_n->blim[filter_level]);
|
|
|
|
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_mbh
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, post->y_stride, lfi_n->mblim[filter_level]);
|
|
|
|
|
|
|
|
if (!skip_lf)
|
2012-01-13 01:15:42 +01:00
|
|
|
vp8_loop_filter_simple_bh
|
2011-06-10 13:10:21 +02:00
|
|
|
(y_ptr, post->y_stride, lfi_n->blim[filter_level]);
|
|
|
|
}
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
y_ptr += 16;
|
2011-06-10 13:10:21 +02:00
|
|
|
mode_info_context += 1; /* step to next MB */
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
y_ptr += post->y_stride * 16 - post->y_width;
|
2011-06-10 13:10:21 +02:00
|
|
|
mode_info_context += 1; /* Skip border mb */
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|