From patchwork Mon Dec 2 07:29:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hwren X-Patchwork-Id: 16524 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 47D5D44AE28 for ; Mon, 2 Dec 2019 10:01:17 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1B96168AACC; Mon, 2 Dec 2019 10:01:17 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-m963.mail.126.com (mail-m963.mail.126.com [123.126.96.3]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9F6E368AACC for ; Mon, 2 Dec 2019 10:01:09 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=X2oHK5qyWX67K094Yg CWJl9opELgjBaC4ucf24HOpig=; b=ctQNvr4W2o2SN4JNe6MqWQ1y8L6mZAwxPC w3c/khWMRjU5tCNTIpHO5mH9l/pSB6BzedTQuLzScWR30y5mROuS0KyNvCzUGucv DdsMSlblahb3DOXMPvSlo3z1pqTkfMcsFPRfBFFHaNvUKe/d1bdrvvqU70S5Oqb7 OeFxewiWs= Received: from localhost.localdomain (unknown [114.242.250.14]) by smtp8 (Coremail) with SMTP id NORpCgDH9f1nveRdvJacAA--.787S4; Mon, 02 Dec 2019 15:29:45 +0800 (CST) From: hwren To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Dec 2019 15:29:37 +0800 Message-Id: <1575271780-20422-2-git-send-email-hwrenx@126.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1575271780-20422-1-git-send-email-hwrenx@126.com> References: <1575271780-20422-1-git-send-email-hwrenx@126.com> X-CM-TRANSID: NORpCgDH9f1nveRdvJacAA--.787S4 X-Coremail-Antispam: 1Uf129KBjvJXoW7Ar47tw1kWF4UurW7Ar4UXFb_yoW8KryUp3 WrCrsxtw15W3WSyrZ3Ar4Sqr43WFZ5Ww18CrsrJr1vqFyYvF1UXry7GFWxu3yUKrsrG34q kFWkK3Z8GF1kJaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j8AwxUUUUU= X-Originating-IP: [114.242.250.14] X-CM-SenderInfo: pkzuv0b06rjloofrz/1tbiTwp-6VpD-GPTPQAAs7 Subject: [FFmpeg-devel] [PATCH 2/5] lavc/libxavs2.c: avoid recomputations of pointers in xavs2_copy_frame* functions 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: hwren --- libavcodec/libxavs2.c | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/libavcodec/libxavs2.c b/libavcodec/libxavs2.c index 3896f3b..6ec6349 100644 --- a/libavcodec/libxavs2.c +++ b/libavcodec/libxavs2.c @@ -132,28 +132,42 @@ static av_cold int xavs2_init(AVCodecContext *avctx) static void xavs2_copy_frame_with_shift(xavs2_picture_t *pic, const AVFrame *frame, const int shift_in) { - int plane, hIdx, wIdx; - for (plane = 0; plane < 3; plane++) { - int i_stride = pic->img.i_stride[plane]; - for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) { - uint16_t *p_plane = (uint16_t *)&pic->img.img_planes[plane][hIdx * i_stride]; - uint8_t *p_buffer = frame->data[plane] + frame->linesize[plane] * hIdx; - memset(p_plane, 0, i_stride); - for (wIdx = 0; wIdx < pic->img.i_width[plane]; wIdx++) { + uint16_t *p_plane; + uint8_t *p_buffer; + int plane; + int hIdx; + int wIdx; + + for (plane = 0; plane < 3; ++plane) { + p_plane = (uint16_t *)pic->img.img_planes[plane]; + p_buffer = frame->data[plane]; + for (hIdx = 0; hIdx < pic->img.i_lines[plane]; ++hIdx) { + memset(p_plane, 0, pic->img.i_stride[plane]); + for (wIdx = 0; wIdx < pic->img.i_width[plane]; ++wIdx) { p_plane[wIdx] = p_buffer[wIdx] << shift_in; } + p_plane += pic->img.i_stride[plane]; + p_buffer += frame->linesize[plane]; } } } static void xavs2_copy_frame(xavs2_picture_t *pic, const AVFrame *frame) { - int plane, hIdx; - for (plane = 0; plane < 3; plane++) { - for (hIdx = 0; hIdx < pic->img.i_lines[plane]; hIdx++) { - memcpy( pic->img.img_planes[plane] + pic->img.i_stride[plane] * hIdx, - frame->data[plane]+frame->linesize[plane] * hIdx, - pic->img.i_width[plane] * pic->img.in_sample_size); + uint8_t *p_plane; + uint8_t *p_buffer; + int plane; + int hIdx; + int stride; + + for (plane = 0; plane < 3; ++plane) { + p_plane = pic->img.img_planes[plane]; + p_buffer = frame->data[plane]; + stride = pic->img.i_width[plane] * pic->img.in_sample_size; + for (hIdx = 0; hIdx < pic->img.i_lines[plane]; ++hIdx) { + memcpy(p_plane, p_buffer, stride); + p_plane += pic->img.i_stride[plane]; + p_buffer += frame->linesize[plane]; } } }