[FFmpeg-cvslog] vvcdec: reuse h26x/h2656_sao_template.c
Nuo Mi
git at videolan.org
Thu Jan 11 17:00:28 EET 2024
ffmpeg | branch: master | Nuo Mi <nuomi2021 at gmail.com> | Sat Jan 6 18:51:30 2024 +0800| [69e179e8bfe3ee9879f36233407d2c39daf8e8c9] | committer: Nuo Mi
vvcdec: reuse h26x/h2656_sao_template.c
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=69e179e8bfe3ee9879f36233407d2c39daf8e8c9
---
libavcodec/vvc/vvc_filter_template.c | 193 +----------------------------------
1 file changed, 2 insertions(+), 191 deletions(-)
diff --git a/libavcodec/vvc/vvc_filter_template.c b/libavcodec/vvc/vvc_filter_template.c
index a4f1792ec4..9418980c33 100644
--- a/libavcodec/vvc/vvc_filter_template.c
+++ b/libavcodec/vvc/vvc_filter_template.c
@@ -20,6 +20,8 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include "libavcodec/h26x/h2656_sao_template.c"
+
static void FUNC(lmcs_filter_luma)(uint8_t *_dst, ptrdiff_t dst_stride, const int width, const int height, const uint8_t *_lut)
{
const pixel *lut = (const pixel *)_lut;
@@ -33,197 +35,6 @@ static void FUNC(lmcs_filter_luma)(uint8_t *_dst, ptrdiff_t dst_stride, const in
}
}
-static void FUNC(sao_band_filter)(uint8_t *_dst, const uint8_t *_src, ptrdiff_t dst_stride, ptrdiff_t src_stride,
- const int16_t *sao_offset_val, const int sao_left_class, const int width, const int height)
-{
- pixel *dst = (pixel *)_dst;
- const pixel *src = (pixel *)_src;
- int offset_table[32] = { 0 };
- int k, y, x;
- int shift = BIT_DEPTH - 5;
-
- dst_stride /= sizeof(pixel);
- src_stride /= sizeof(pixel);
-
- for (k = 0; k < 4; k++)
- offset_table[(k + sao_left_class) & 31] = sao_offset_val[k + 1];
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++)
- dst[x] = av_clip_pixel(src[x] + offset_table[src[x] >> shift]);
- dst += dst_stride;
- src += src_stride;
- }
-}
-
-#define CMP(a, b) (((a) > (b)) - ((a) < (b)))
-
-static void FUNC(sao_edge_filter)(uint8_t *_dst, const uint8_t *_src, ptrdiff_t dst_stride,
- const int16_t *sao_offset_val, const int eo, const int width, const int height)
-{
- static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
- static const int8_t pos[4][2][2] = {
- { { -1, 0 }, { 1, 0 } }, // horizontal
- { { 0, -1 }, { 0, 1 } }, // vertical
- { { -1, -1 }, { 1, 1 } }, // 45 degree
- { { 1, -1 }, { -1, 1 } }, // 135 degree
- };
- pixel *dst = (pixel *)_dst;
- const pixel *src = (pixel *)_src;
- int a_stride, b_stride;
- int x, y;
- ptrdiff_t src_stride = (2 * MAX_PB_SIZE + AV_INPUT_BUFFER_PADDING_SIZE) / sizeof(pixel);
- dst_stride /= sizeof(pixel);
-
- a_stride = pos[eo][0][0] + pos[eo][0][1] * src_stride;
- b_stride = pos[eo][1][0] + pos[eo][1][1] * src_stride;
- for (y = 0; y < height; y++) {
- for (x = 0; x < width; x++) {
- int diff0 = CMP(src[x], src[x + a_stride]);
- int diff1 = CMP(src[x], src[x + b_stride]);
- int offset_val = edge_idx[2 + diff0 + diff1];
- dst[x] = av_clip_pixel(src[x] + sao_offset_val[offset_val]);
- }
- src += src_stride;
- dst += dst_stride;
- }
-}
-
-static void FUNC(sao_edge_restore_0)(uint8_t *_dst, const uint8_t *_src,
- ptrdiff_t dst_stride, ptrdiff_t src_stride, const SAOParams *sao,
- const int *borders, const int _width, const int _height, const int c_idx,
- const uint8_t *vert_edge, const uint8_t *horiz_edge, const uint8_t *diag_edge)
-{
- int x, y;
- pixel *dst = (pixel *)_dst;
- const pixel *src = (pixel *)_src;
- const int16_t *sao_offset_val = sao->offset_val[c_idx];
- const int sao_eo_class = sao->eo_class[c_idx];
- int init_x = 0, width = _width, height = _height;
-
- dst_stride /= sizeof(pixel);
- src_stride /= sizeof(pixel);
-
- if (sao_eo_class != SAO_EO_VERT) {
- if (borders[0]) {
- int offset_val = sao_offset_val[0];
- for (y = 0; y < height; y++) {
- dst[y * dst_stride] = av_clip_pixel(src[y * src_stride] + offset_val);
- }
- init_x = 1;
- }
- if (borders[2]) {
- int offset_val = sao_offset_val[0];
- int offset = width - 1;
- for (x = 0; x < height; x++) {
- dst[x * dst_stride + offset] = av_clip_pixel(src[x * src_stride + offset] + offset_val);
- }
- width--;
- }
- }
- if (sao_eo_class != SAO_EO_HORIZ) {
- if (borders[1]) {
- int offset_val = sao_offset_val[0];
- for (x = init_x; x < width; x++)
- dst[x] = av_clip_pixel(src[x] + offset_val);
- }
- if (borders[3]) {
- int offset_val = sao_offset_val[0];
- ptrdiff_t y_dst_stride = dst_stride * (height - 1);
- ptrdiff_t y_src_stride = src_stride * (height - 1);
- for (x = init_x; x < width; x++)
- dst[x + y_dst_stride] = av_clip_pixel(src[x + y_src_stride] + offset_val);
- height--;
- }
- }
-}
-
-static void FUNC(sao_edge_restore_1)(uint8_t *_dst, const uint8_t *_src,
- ptrdiff_t dst_stride, ptrdiff_t src_stride, const SAOParams *sao,
- const int *borders, const int _width, const int _height, const int c_idx,
- const uint8_t *vert_edge, const uint8_t *horiz_edge, const uint8_t *diag_edge)
-{
- int x, y;
- pixel *dst = (pixel *)_dst;
- const pixel *src = (pixel *)_src;
- const int16_t *sao_offset_val = sao->offset_val[c_idx];
- const int sao_eo_class = sao->eo_class[c_idx];
- int init_x = 0, init_y = 0, width = _width, height = _height;
-
- dst_stride /= sizeof(pixel);
- src_stride /= sizeof(pixel);
-
- if (sao_eo_class != SAO_EO_VERT) {
- if (borders[0]) {
- int offset_val = sao_offset_val[0];
- for (y = 0; y < height; y++) {
- dst[y * dst_stride] = av_clip_pixel(src[y * src_stride] + offset_val);
- }
- init_x = 1;
- }
- if (borders[2]) {
- int offset_val = sao_offset_val[0];
- int offset = width - 1;
- for (x = 0; x < height; x++) {
- dst[x * dst_stride + offset] = av_clip_pixel(src[x * src_stride + offset] + offset_val);
- }
- width--;
- }
- }
- if (sao_eo_class != SAO_EO_HORIZ) {
- if (borders[1]) {
- int offset_val = sao_offset_val[0];
- for (x = init_x; x < width; x++)
- dst[x] = av_clip_pixel(src[x] + offset_val);
- init_y = 1;
- }
- if (borders[3]) {
- int offset_val = sao_offset_val[0];
- ptrdiff_t y_dst_stride = dst_stride * (height - 1);
- ptrdiff_t y_src_stride = src_stride * (height - 1);
- for (x = init_x; x < width; x++)
- dst[x + y_dst_stride] = av_clip_pixel(src[x + y_src_stride] + offset_val);
- height--;
- }
- }
-
- {
- int save_upper_left = !diag_edge[0] && sao_eo_class == SAO_EO_135D && !borders[0] && !borders[1];
- int save_upper_right = !diag_edge[1] && sao_eo_class == SAO_EO_45D && !borders[1] && !borders[2];
- int save_lower_right = !diag_edge[2] && sao_eo_class == SAO_EO_135D && !borders[2] && !borders[3];
- int save_lower_left = !diag_edge[3] && sao_eo_class == SAO_EO_45D && !borders[0] && !borders[3];
-
- // Restore pixels that can't be modified
- if (vert_edge[0] && sao_eo_class != SAO_EO_VERT) {
- for (y = init_y + save_upper_left; y < height - save_lower_left; y++)
- dst[y * dst_stride] = src[y * src_stride];
- }
- if (vert_edge[1] && sao_eo_class != SAO_EO_VERT) {
- for (y = init_y + save_upper_right; y < height - save_lower_right; y++)
- dst[y * dst_stride + width - 1] = src[y * src_stride + width - 1];
- }
-
- if (horiz_edge[0] && sao_eo_class != SAO_EO_HORIZ) {
- for (x = init_x + save_upper_left; x < width - save_upper_right; x++)
- dst[x] = src[x];
- }
- if (horiz_edge[1] && sao_eo_class != SAO_EO_HORIZ) {
- for (x = init_x + save_lower_left; x < width - save_lower_right; x++)
- dst[(height - 1) * dst_stride + x] = src[(height - 1) * src_stride + x];
- }
- if (diag_edge[0] && sao_eo_class == SAO_EO_135D)
- dst[0] = src[0];
- if (diag_edge[1] && sao_eo_class == SAO_EO_45D)
- dst[width - 1] = src[width - 1];
- if (diag_edge[2] && sao_eo_class == SAO_EO_135D)
- dst[dst_stride * (height - 1) + width - 1] = src[src_stride * (height - 1) + width - 1];
- if (diag_edge[3] && sao_eo_class == SAO_EO_45D)
- dst[dst_stride * (height - 1)] = src[src_stride * (height - 1)];
-
- }
-}
-
-#undef CMP
-
static av_always_inline int16_t FUNC(alf_clip)(pixel curr, pixel v0, pixel v1, int16_t clip)
{
return av_clip(v0 - curr, -clip, clip) + av_clip(v1 - curr, -clip, clip);
More information about the ffmpeg-cvslog
mailing list