From patchwork Mon Mar 27 21:35:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Ronald S. Bultje" X-Patchwork-Id: 3136 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.44.195 with SMTP id s186csp350945vss; Mon, 27 Mar 2017 14:36:02 -0700 (PDT) X-Received: by 10.28.178.142 with SMTP id b136mr11369025wmf.57.1490650562294; Mon, 27 Mar 2017 14:36:02 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 32si2195490wrc.11.2017.03.27.14.36.01; Mon, 27 Mar 2017 14:36:02 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 680676891E2; Tue, 28 Mar 2017 00:35:28 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk0-f196.google.com (mail-qk0-f196.google.com [209.85.220.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8B3336883C7 for ; Tue, 28 Mar 2017 00:35:21 +0300 (EEST) Received: by mail-qk0-f196.google.com with SMTP id 10so3547912qkh.1 for ; Mon, 27 Mar 2017 14:35:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jBFNegym1DCoC5hxdFUZZ8wVX3d0TBx4Fu4p0ImM6jA=; b=TkkoXzfzXG4bLu+JgrCzcAbvMUoQeXbivvwh4Hf/x3ULP6i8sm3L8911l6UKGUtAiK 8pmstaInUyB0/LzCscKm1t1D9/uQ9gqRrywGEvii3GId7ELgLJ0irg2Fh1eplzeZv/Ga ge9snAScsIOQ9LAHs8ub9KfGdfa7yPTc++Gs4q3slOQLws4LqUP4dqGB3uizV5vHjcWA WfKFHIyacn/+i4XG5CHeB5jG+aBYzRhlBls+TIyOrYosHAzyY7COaz61GLhT9xY61uoX rNfSbtA0BYxb29c7LPZvvUkfb0RFShLrEXilZr/loDDT5ITg2PCsU3CtvZIZBIIt5eDw v38Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jBFNegym1DCoC5hxdFUZZ8wVX3d0TBx4Fu4p0ImM6jA=; b=XrWDmEKZWMsFEpvhsfIW7+lzF6mNEAWaVzkF+JHp9UpWMlDe8MoXqytdcRwQdhzknm RNIom8Fd7NKOOwlpMHFqAqpjlgB96H75mBUMFctu6DbjTY03c476mfLcrWulfTJWjNBr dl3NB4POLN7BGSnOmz8/S8EdaqJs5zmO1p+oeI+kgVefo2hBV8OdmFpm1XDNKzFTuIuZ iMneifLhB95e0q3keoVSw+xLT3l5mcim5e054iHGjU+Hit+6fRFAuEMc1LZwNB42Xd98 8NYoaKyYUwCS21ClJ6m6cccHhbuUZjhshLhZ6+SPcfrNo0Exr7owTYPOF/LztHXZ+8eD BVNQ== X-Gm-Message-State: AFeK/H2C8pJb+fUzt4YmDEZk/+F4Ui7KeqKq4U/eKq04HESpG2AvY51GpAioumHaHbAE/g== X-Received: by 10.55.118.129 with SMTP id r123mr21475850qkc.151.1490650542223; Mon, 27 Mar 2017 14:35:42 -0700 (PDT) Received: from localhost.localdomain ([65.206.95.146]) by smtp.gmail.com with ESMTPSA id w55sm1251412qtw.9.2017.03.27.14.35.41 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 27 Mar 2017 14:35:41 -0700 (PDT) From: "Ronald S. Bultje" To: ffmpeg-devel@ffmpeg.org Date: Mon, 27 Mar 2017 17:35:33 -0400 Message-Id: <1490650535-81794-2-git-send-email-rsbultje@gmail.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1490650535-81794-1-git-send-email-rsbultje@gmail.com> References: <1490650535-81794-1-git-send-email-rsbultje@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] vp9: split out loopfilter functions in their own source file. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: "Ronald S. Bultje" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavcodec/Makefile | 2 +- libavcodec/vp9.c | 181 +--------------------------------------------- libavcodec/vp9dec.h | 3 + libavcodec/vp9lpf.c | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 208 insertions(+), 180 deletions(-) create mode 100644 libavcodec/vp9lpf.c diff --git a/libavcodec/Makefile b/libavcodec/Makefile index cf7ba25..5651526 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -610,7 +610,7 @@ OBJS-$(CONFIG_VP8_DECODER) += vp8.o vp56rac.o OBJS-$(CONFIG_VP8_CUVID_DECODER) += cuvid.o OBJS-$(CONFIG_VP8_MEDIACODEC_DECODER) += mediacodecdec.o OBJS-$(CONFIG_VP8_VAAPI_ENCODER) += vaapi_encode_vp8.o -OBJS-$(CONFIG_VP9_DECODER) += vp9.o vp9data.o vp9dsp.o \ +OBJS-$(CONFIG_VP9_DECODER) += vp9.o vp9data.o vp9dsp.o vp9lpf.o \ vp9block.o vp9prob.o vp9mvs.o vp56rac.o \ vp9dsp_8bpp.o vp9dsp_10bpp.o vp9dsp_12bpp.o OBJS-$(CONFIG_VP9_CUVID_DECODER) += cuvid.o diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 01b6a1b..4d7310f 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -1056,184 +1056,6 @@ static void decode_sb_mem(AVCodecContext *avctx, int row, int col, VP9Filter *lf } } -static av_always_inline void filter_plane_cols(VP9Context *s, int col, int ss_h, int ss_v, - uint8_t *lvl, uint8_t (*mask)[4], - uint8_t *dst, ptrdiff_t ls) -{ - int y, x, bytesperpixel = s->bytesperpixel; - - // filter edges between columns (e.g. block1 | block2) - for (y = 0; y < 8; y += 2 << ss_v, dst += 16 * ls, lvl += 16 << ss_v) { - uint8_t *ptr = dst, *l = lvl, *hmask1 = mask[y], *hmask2 = mask[y + 1 + ss_v]; - unsigned hm1 = hmask1[0] | hmask1[1] | hmask1[2], hm13 = hmask1[3]; - unsigned hm2 = hmask2[1] | hmask2[2], hm23 = hmask2[3]; - unsigned hm = hm1 | hm2 | hm13 | hm23; - - for (x = 1; hm & ~(x - 1); x <<= 1, ptr += 8 * bytesperpixel >> ss_h) { - if (col || x > 1) { - if (hm1 & x) { - int L = *l, H = L >> 4; - int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; - - if (hmask1[0] & x) { - if (hmask2[0] & x) { - av_assert2(l[8 << ss_v] == L); - s->dsp.loop_filter_16[0](ptr, ls, E, I, H); - } else { - s->dsp.loop_filter_8[2][0](ptr, ls, E, I, H); - } - } else if (hm2 & x) { - L = l[8 << ss_v]; - H |= (L >> 4) << 8; - E |= s->filter_lut.mblim_lut[L] << 8; - I |= s->filter_lut.lim_lut[L] << 8; - s->dsp.loop_filter_mix2[!!(hmask1[1] & x)] - [!!(hmask2[1] & x)] - [0](ptr, ls, E, I, H); - } else { - s->dsp.loop_filter_8[!!(hmask1[1] & x)] - [0](ptr, ls, E, I, H); - } - } else if (hm2 & x) { - int L = l[8 << ss_v], H = L >> 4; - int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; - - s->dsp.loop_filter_8[!!(hmask2[1] & x)] - [0](ptr + 8 * ls, ls, E, I, H); - } - } - if (ss_h) { - if (x & 0xAA) - l += 2; - } else { - if (hm13 & x) { - int L = *l, H = L >> 4; - int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; - - if (hm23 & x) { - L = l[8 << ss_v]; - H |= (L >> 4) << 8; - E |= s->filter_lut.mblim_lut[L] << 8; - I |= s->filter_lut.lim_lut[L] << 8; - s->dsp.loop_filter_mix2[0][0][0](ptr + 4 * bytesperpixel, ls, E, I, H); - } else { - s->dsp.loop_filter_8[0][0](ptr + 4 * bytesperpixel, ls, E, I, H); - } - } else if (hm23 & x) { - int L = l[8 << ss_v], H = L >> 4; - int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; - - s->dsp.loop_filter_8[0][0](ptr + 8 * ls + 4 * bytesperpixel, ls, E, I, H); - } - l++; - } - } - } -} - -static av_always_inline void filter_plane_rows(VP9Context *s, int row, int ss_h, int ss_v, - uint8_t *lvl, uint8_t (*mask)[4], - uint8_t *dst, ptrdiff_t ls) -{ - int y, x, bytesperpixel = s->bytesperpixel; - - // block1 - // filter edges between rows (e.g. ------) - // block2 - for (y = 0; y < 8; y++, dst += 8 * ls >> ss_v) { - uint8_t *ptr = dst, *l = lvl, *vmask = mask[y]; - unsigned vm = vmask[0] | vmask[1] | vmask[2], vm3 = vmask[3]; - - for (x = 1; vm & ~(x - 1); x <<= (2 << ss_h), ptr += 16 * bytesperpixel, l += 2 << ss_h) { - if (row || y) { - if (vm & x) { - int L = *l, H = L >> 4; - int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; - - if (vmask[0] & x) { - if (vmask[0] & (x << (1 + ss_h))) { - av_assert2(l[1 + ss_h] == L); - s->dsp.loop_filter_16[1](ptr, ls, E, I, H); - } else { - s->dsp.loop_filter_8[2][1](ptr, ls, E, I, H); - } - } else if (vm & (x << (1 + ss_h))) { - L = l[1 + ss_h]; - H |= (L >> 4) << 8; - E |= s->filter_lut.mblim_lut[L] << 8; - I |= s->filter_lut.lim_lut[L] << 8; - s->dsp.loop_filter_mix2[!!(vmask[1] & x)] - [!!(vmask[1] & (x << (1 + ss_h)))] - [1](ptr, ls, E, I, H); - } else { - s->dsp.loop_filter_8[!!(vmask[1] & x)] - [1](ptr, ls, E, I, H); - } - } else if (vm & (x << (1 + ss_h))) { - int L = l[1 + ss_h], H = L >> 4; - int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; - - s->dsp.loop_filter_8[!!(vmask[1] & (x << (1 + ss_h)))] - [1](ptr + 8 * bytesperpixel, ls, E, I, H); - } - } - if (!ss_v) { - if (vm3 & x) { - int L = *l, H = L >> 4; - int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; - - if (vm3 & (x << (1 + ss_h))) { - L = l[1 + ss_h]; - H |= (L >> 4) << 8; - E |= s->filter_lut.mblim_lut[L] << 8; - I |= s->filter_lut.lim_lut[L] << 8; - s->dsp.loop_filter_mix2[0][0][1](ptr + ls * 4, ls, E, I, H); - } else { - s->dsp.loop_filter_8[0][1](ptr + ls * 4, ls, E, I, H); - } - } else if (vm3 & (x << (1 + ss_h))) { - int L = l[1 + ss_h], H = L >> 4; - int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; - - s->dsp.loop_filter_8[0][1](ptr + ls * 4 + 8 * bytesperpixel, ls, E, I, H); - } - } - } - if (ss_v) { - if (y & 1) - lvl += 16; - } else { - lvl += 8; - } - } -} - -static void loopfilter_sb(AVCodecContext *avctx, VP9Filter *lflvl, - int row, int col, ptrdiff_t yoff, ptrdiff_t uvoff) -{ - VP9Context *s = avctx->priv_data; - AVFrame *f = s->s.frames[CUR_FRAME].tf.f; - uint8_t *dst = f->data[0] + yoff; - ptrdiff_t ls_y = f->linesize[0], ls_uv = f->linesize[1]; - uint8_t (*uv_masks)[8][4] = lflvl->mask[s->ss_h | s->ss_v]; - int p; - - /* FIXME: In how far can we interleave the v/h loopfilter calls? E.g. - * if you think of them as acting on a 8x8 block max, we can interleave - * each v/h within the single x loop, but that only works if we work on - * 8 pixel blocks, and we won't always do that (we want at least 16px - * to use SSE2 optimizations, perhaps 32 for AVX2) */ - - filter_plane_cols(s, col, 0, 0, lflvl->level, lflvl->mask[0][0], dst, ls_y); - filter_plane_rows(s, row, 0, 0, lflvl->level, lflvl->mask[0][1], dst, ls_y); - - for (p = 0; p < 2; p++) { - dst = f->data[1 + p] + uvoff; - filter_plane_cols(s, col, s->ss_h, s->ss_v, lflvl->level, uv_masks[0], dst, ls_uv); - filter_plane_rows(s, row, s->ss_h, s->ss_v, lflvl->level, uv_masks[1], dst, ls_uv); - } -} - static void set_tile_offset(int *start, int *end, int idx, int log2_n, int n) { int sb_start = ( idx * n) >> log2_n; @@ -1522,7 +1344,8 @@ FF_ENABLE_DEPRECATION_WARNINGS for (col = 0; col < s->cols; col += 8, yoff2 += 64 * bytesperpixel, uvoff2 += 64 * bytesperpixel >> s->ss_h, lflvl_ptr++) { - loopfilter_sb(avctx, lflvl_ptr, row, col, yoff2, uvoff2); + ff_vp9_loopfilter_sb(avctx, lflvl_ptr, row, col, + yoff2, uvoff2); } } diff --git a/libavcodec/vp9dec.h b/libavcodec/vp9dec.h index ba821f3..1f3348a 100644 --- a/libavcodec/vp9dec.h +++ b/libavcodec/vp9dec.h @@ -203,4 +203,7 @@ void ff_vp9_decode_block(AVCodecContext *ctx, int row, int col, VP9Filter *lflvl, ptrdiff_t yoff, ptrdiff_t uvoff, enum BlockLevel bl, enum BlockPartition bp); +void ff_vp9_loopfilter_sb(AVCodecContext *avctx, VP9Filter *lflvl, + int row, int col, ptrdiff_t yoff, ptrdiff_t uvoff); + #endif /* AVCODEC_VP9DEC_H */ diff --git a/libavcodec/vp9lpf.c b/libavcodec/vp9lpf.c new file mode 100644 index 0000000..414cede --- /dev/null +++ b/libavcodec/vp9lpf.c @@ -0,0 +1,202 @@ +/* + * VP9 compatible video decoder + * + * Copyright (C) 2013 Ronald S. Bultje + * Copyright (C) 2013 Clément Bœsch + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "vp9dec.h" + +static av_always_inline void filter_plane_cols(VP9Context *s, int col, int ss_h, int ss_v, + uint8_t *lvl, uint8_t (*mask)[4], + uint8_t *dst, ptrdiff_t ls) +{ + int y, x, bytesperpixel = s->bytesperpixel; + + // filter edges between columns (e.g. block1 | block2) + for (y = 0; y < 8; y += 2 << ss_v, dst += 16 * ls, lvl += 16 << ss_v) { + uint8_t *ptr = dst, *l = lvl, *hmask1 = mask[y], *hmask2 = mask[y + 1 + ss_v]; + unsigned hm1 = hmask1[0] | hmask1[1] | hmask1[2], hm13 = hmask1[3]; + unsigned hm2 = hmask2[1] | hmask2[2], hm23 = hmask2[3]; + unsigned hm = hm1 | hm2 | hm13 | hm23; + + for (x = 1; hm & ~(x - 1); x <<= 1, ptr += 8 * bytesperpixel >> ss_h) { + if (col || x > 1) { + if (hm1 & x) { + int L = *l, H = L >> 4; + int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; + + if (hmask1[0] & x) { + if (hmask2[0] & x) { + av_assert2(l[8 << ss_v] == L); + s->dsp.loop_filter_16[0](ptr, ls, E, I, H); + } else { + s->dsp.loop_filter_8[2][0](ptr, ls, E, I, H); + } + } else if (hm2 & x) { + L = l[8 << ss_v]; + H |= (L >> 4) << 8; + E |= s->filter_lut.mblim_lut[L] << 8; + I |= s->filter_lut.lim_lut[L] << 8; + s->dsp.loop_filter_mix2[!!(hmask1[1] & x)] + [!!(hmask2[1] & x)] + [0](ptr, ls, E, I, H); + } else { + s->dsp.loop_filter_8[!!(hmask1[1] & x)] + [0](ptr, ls, E, I, H); + } + } else if (hm2 & x) { + int L = l[8 << ss_v], H = L >> 4; + int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; + + s->dsp.loop_filter_8[!!(hmask2[1] & x)] + [0](ptr + 8 * ls, ls, E, I, H); + } + } + if (ss_h) { + if (x & 0xAA) + l += 2; + } else { + if (hm13 & x) { + int L = *l, H = L >> 4; + int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; + + if (hm23 & x) { + L = l[8 << ss_v]; + H |= (L >> 4) << 8; + E |= s->filter_lut.mblim_lut[L] << 8; + I |= s->filter_lut.lim_lut[L] << 8; + s->dsp.loop_filter_mix2[0][0][0](ptr + 4 * bytesperpixel, ls, E, I, H); + } else { + s->dsp.loop_filter_8[0][0](ptr + 4 * bytesperpixel, ls, E, I, H); + } + } else if (hm23 & x) { + int L = l[8 << ss_v], H = L >> 4; + int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; + + s->dsp.loop_filter_8[0][0](ptr + 8 * ls + 4 * bytesperpixel, ls, E, I, H); + } + l++; + } + } + } +} + +static av_always_inline void filter_plane_rows(VP9Context *s, int row, int ss_h, int ss_v, + uint8_t *lvl, uint8_t (*mask)[4], + uint8_t *dst, ptrdiff_t ls) +{ + int y, x, bytesperpixel = s->bytesperpixel; + + // block1 + // filter edges between rows (e.g. ------) + // block2 + for (y = 0; y < 8; y++, dst += 8 * ls >> ss_v) { + uint8_t *ptr = dst, *l = lvl, *vmask = mask[y]; + unsigned vm = vmask[0] | vmask[1] | vmask[2], vm3 = vmask[3]; + + for (x = 1; vm & ~(x - 1); x <<= (2 << ss_h), ptr += 16 * bytesperpixel, l += 2 << ss_h) { + if (row || y) { + if (vm & x) { + int L = *l, H = L >> 4; + int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; + + if (vmask[0] & x) { + if (vmask[0] & (x << (1 + ss_h))) { + av_assert2(l[1 + ss_h] == L); + s->dsp.loop_filter_16[1](ptr, ls, E, I, H); + } else { + s->dsp.loop_filter_8[2][1](ptr, ls, E, I, H); + } + } else if (vm & (x << (1 + ss_h))) { + L = l[1 + ss_h]; + H |= (L >> 4) << 8; + E |= s->filter_lut.mblim_lut[L] << 8; + I |= s->filter_lut.lim_lut[L] << 8; + s->dsp.loop_filter_mix2[!!(vmask[1] & x)] + [!!(vmask[1] & (x << (1 + ss_h)))] + [1](ptr, ls, E, I, H); + } else { + s->dsp.loop_filter_8[!!(vmask[1] & x)] + [1](ptr, ls, E, I, H); + } + } else if (vm & (x << (1 + ss_h))) { + int L = l[1 + ss_h], H = L >> 4; + int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; + + s->dsp.loop_filter_8[!!(vmask[1] & (x << (1 + ss_h)))] + [1](ptr + 8 * bytesperpixel, ls, E, I, H); + } + } + if (!ss_v) { + if (vm3 & x) { + int L = *l, H = L >> 4; + int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; + + if (vm3 & (x << (1 + ss_h))) { + L = l[1 + ss_h]; + H |= (L >> 4) << 8; + E |= s->filter_lut.mblim_lut[L] << 8; + I |= s->filter_lut.lim_lut[L] << 8; + s->dsp.loop_filter_mix2[0][0][1](ptr + ls * 4, ls, E, I, H); + } else { + s->dsp.loop_filter_8[0][1](ptr + ls * 4, ls, E, I, H); + } + } else if (vm3 & (x << (1 + ss_h))) { + int L = l[1 + ss_h], H = L >> 4; + int E = s->filter_lut.mblim_lut[L], I = s->filter_lut.lim_lut[L]; + + s->dsp.loop_filter_8[0][1](ptr + ls * 4 + 8 * bytesperpixel, ls, E, I, H); + } + } + } + if (ss_v) { + if (y & 1) + lvl += 16; + } else { + lvl += 8; + } + } +} + +void ff_vp9_loopfilter_sb(AVCodecContext *avctx, VP9Filter *lflvl, + int row, int col, ptrdiff_t yoff, ptrdiff_t uvoff) +{ + VP9Context *s = avctx->priv_data; + AVFrame *f = s->s.frames[CUR_FRAME].tf.f; + uint8_t *dst = f->data[0] + yoff; + ptrdiff_t ls_y = f->linesize[0], ls_uv = f->linesize[1]; + uint8_t (*uv_masks)[8][4] = lflvl->mask[s->ss_h | s->ss_v]; + int p; + + /* FIXME: In how far can we interleave the v/h loopfilter calls? E.g. + * if you think of them as acting on a 8x8 block max, we can interleave + * each v/h within the single x loop, but that only works if we work on + * 8 pixel blocks, and we won't always do that (we want at least 16px + * to use SSE2 optimizations, perhaps 32 for AVX2) */ + + filter_plane_cols(s, col, 0, 0, lflvl->level, lflvl->mask[0][0], dst, ls_y); + filter_plane_rows(s, row, 0, 0, lflvl->level, lflvl->mask[0][1], dst, ls_y); + + for (p = 0; p < 2; p++) { + dst = f->data[1 + p] + uvoff; + filter_plane_cols(s, col, s->ss_h, s->ss_v, lflvl->level, uv_masks[0], dst, ls_uv); + filter_plane_rows(s, row, s->ss_h, s->ss_v, lflvl->level, uv_masks[1], dst, ls_uv); + } +}