hevcdsp: simplified sao_edge_filter

Reviewed-by: Christophe Gisquet <christophe.gisquet@gmail.com>
Reviewed-by: Mickaël Raulet <mraulet@insa-rennes.fr>
This commit is contained in:
Seppo Tomperi 2015-02-03 22:36:42 -03:00 committed by James Almer
parent 74d7faf400
commit 4386e1fd94
3 changed files with 18 additions and 22 deletions

View File

@ -427,7 +427,7 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx,
x_ctb, y_ctb);
s->hevcdsp.sao_edge_filter(src, dst, stride_src, stride_dst, sao, width, height, c_idx, 0, 0);
s->hevcdsp.sao_edge_filter(src, dst, stride_src, stride_dst, sao, width, height, c_idx);
s->hevcdsp.sao_edge_restore[restore](src, dst,
stride_src, stride_dst,
sao,

View File

@ -63,7 +63,7 @@ typedef struct HEVCDSPContext {
void (*sao_edge_filter)(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst,
ptrdiff_t stride_src, SAOParams *sao, int width,
int height, int c_idx, int init_x, int init_y);
int height, int c_idx);
void (*sao_edge_restore[2])(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,
struct SAOParams *sao, int *borders, int _width, int _height, int c_idx,

View File

@ -330,7 +330,7 @@ static void FUNC(sao_band_filter_0)(uint8_t *_dst, uint8_t *_src,
static void FUNC(sao_edge_filter)(uint8_t *_dst, uint8_t *_src,
ptrdiff_t stride_dst, ptrdiff_t stride_src, SAOParams *sao,
int width, int height,
int c_idx, int init_x, int init_y) {
int c_idx) {
static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
static const int8_t pos[4][2][2] = {
@ -340,31 +340,27 @@ static void FUNC(sao_edge_filter)(uint8_t *_dst, uint8_t *_src,
{ { 1, -1 }, { -1, 1 } }, // 135 degree
};
int16_t *sao_offset_val = sao->offset_val[c_idx];
int sao_eo_class = sao->eo_class[c_idx];
int eo = sao->eo_class[c_idx];
pixel *dst = (pixel *)_dst;
pixel *src = (pixel *)_src;
int y_stride_src = init_y * (stride_src /= sizeof(pixel));
int y_stride_dst = init_y * (stride_dst /= sizeof(pixel));
int pos_0_0 = pos[sao_eo_class][0][0];
int pos_0_1 = pos[sao_eo_class][0][1];
int pos_1_0 = pos[sao_eo_class][1][0];
int pos_1_1 = pos[sao_eo_class][1][1];
int a_stride, b_stride;
int src_offset = 0;
int dst_offset = 0;
int x, y;
stride_src /= sizeof(pixel);
stride_dst /= sizeof(pixel);
int y_stride_0_1 = (init_y + pos_0_1) * stride_src;
int y_stride_1_1 = (init_y + pos_1_1) * stride_src;
for (y = init_y; y < height; y++) {
for (x = init_x; x < width; x++) {
int diff0 = CMP(src[x + y_stride_src], src[x + pos_0_0 + y_stride_0_1]);
int diff1 = CMP(src[x + y_stride_src], src[x + pos_1_0 + y_stride_1_1]);
a_stride = pos[eo][0][0] + pos[eo][0][1] * stride_src;
b_stride = pos[eo][1][0] + pos[eo][1][1] * stride_src;
for (y = 0; y < height; y++) {
for (x = 0; x < width; x++) {
int diff0 = CMP(src[x + src_offset], src[x + src_offset + a_stride]);
int diff1 = CMP(src[x + src_offset], src[x + src_offset + b_stride]);
int offset_val = edge_idx[2 + diff0 + diff1];
dst[x + y_stride_dst] = av_clip_pixel(src[x + y_stride_src] + sao_offset_val[offset_val]);
dst[x + dst_offset] = av_clip_pixel(src[x + src_offset] + sao_offset_val[offset_val]);
}
y_stride_src += stride_src;
y_stride_dst += stride_dst;
y_stride_0_1 += stride_src;
y_stride_1_1 += stride_src;
src_offset += stride_src;
dst_offset += stride_dst;
}
}