mirror of https://git.ffmpeg.org/ffmpeg.git
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:
parent
74d7faf400
commit
4386e1fd94
|
@ -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,
|
copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx,
|
||||||
x_ctb, y_ctb);
|
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,
|
s->hevcdsp.sao_edge_restore[restore](src, dst,
|
||||||
stride_src, stride_dst,
|
stride_src, stride_dst,
|
||||||
sao,
|
sao,
|
||||||
|
|
|
@ -63,7 +63,7 @@ typedef struct HEVCDSPContext {
|
||||||
|
|
||||||
void (*sao_edge_filter)(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst,
|
void (*sao_edge_filter)(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst,
|
||||||
ptrdiff_t stride_src, SAOParams *sao, int width,
|
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,
|
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,
|
struct SAOParams *sao, int *borders, int _width, int _height, int c_idx,
|
||||||
|
|
|
@ -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,
|
static void FUNC(sao_edge_filter)(uint8_t *_dst, uint8_t *_src,
|
||||||
ptrdiff_t stride_dst, ptrdiff_t stride_src, SAOParams *sao,
|
ptrdiff_t stride_dst, ptrdiff_t stride_src, SAOParams *sao,
|
||||||
int width, int height,
|
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 uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
|
||||||
static const int8_t pos[4][2][2] = {
|
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
|
{ { 1, -1 }, { -1, 1 } }, // 135 degree
|
||||||
};
|
};
|
||||||
int16_t *sao_offset_val = sao->offset_val[c_idx];
|
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 *dst = (pixel *)_dst;
|
||||||
pixel *src = (pixel *)_src;
|
pixel *src = (pixel *)_src;
|
||||||
|
int a_stride, b_stride;
|
||||||
int y_stride_src = init_y * (stride_src /= sizeof(pixel));
|
int src_offset = 0;
|
||||||
int y_stride_dst = init_y * (stride_dst /= sizeof(pixel));
|
int dst_offset = 0;
|
||||||
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 x, y;
|
int x, y;
|
||||||
|
stride_src /= sizeof(pixel);
|
||||||
|
stride_dst /= sizeof(pixel);
|
||||||
|
|
||||||
int y_stride_0_1 = (init_y + pos_0_1) * stride_src;
|
a_stride = pos[eo][0][0] + pos[eo][0][1] * stride_src;
|
||||||
int y_stride_1_1 = (init_y + pos_1_1) * stride_src;
|
b_stride = pos[eo][1][0] + pos[eo][1][1] * stride_src;
|
||||||
for (y = init_y; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
for (x = init_x; x < width; x++) {
|
for (x = 0; x < width; x++) {
|
||||||
int diff0 = CMP(src[x + y_stride_src], src[x + pos_0_0 + y_stride_0_1]);
|
int diff0 = CMP(src[x + src_offset], src[x + src_offset + a_stride]);
|
||||||
int diff1 = CMP(src[x + y_stride_src], src[x + pos_1_0 + y_stride_1_1]);
|
int diff1 = CMP(src[x + src_offset], src[x + src_offset + b_stride]);
|
||||||
int offset_val = edge_idx[2 + diff0 + diff1];
|
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;
|
src_offset += stride_src;
|
||||||
y_stride_dst += stride_dst;
|
dst_offset += stride_dst;
|
||||||
y_stride_0_1 += stride_src;
|
|
||||||
y_stride_1_1 += stride_src;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue