From patchwork Tue Jun 4 15:59:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Fu, Linjie" X-Patchwork-Id: 13405 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 1D3B14457D1 for ; Tue, 4 Jun 2019 10:59:25 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F0AFB689D68; Tue, 4 Jun 2019 10:59:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1515A689D68 for ; Tue, 4 Jun 2019 10:59:17 +0300 (EEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Jun 2019 00:59:16 -0700 X-ExtLoop1: 1 Received: from media_lj_kbl.sh.intel.com ([10.239.13.115]) by fmsmga007.fm.intel.com with ESMTP; 04 Jun 2019 00:59:15 -0700 From: Linjie Fu To: ffmpeg-devel@ffmpeg.org Date: Tue, 4 Jun 2019 23:59:07 +0800 Message-Id: <20190604155907.9980-1-linjie.fu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [FFmpeg-devel] [PATCH,v3] lavf/qsvvpp:allocate continuous memory 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: Linjie Fu MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Mediasdk calls CMRT to copy from video to system memory and requires memory to be continuously allocated across Y and UV. Add a new path to allocate continuous memory when using system out. Use av_frame_get_buffer to arrange data according to pixfmt, and remove the introduced plane_padding. Signed-off-by: Linjie Fu --- libavfilter/qsvvpp.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index 5cd1d5d345..c06171444f 100644 --- a/libavfilter/qsvvpp.c +++ b/libavfilter/qsvvpp.c @@ -350,7 +350,7 @@ static QSVFrame *query_frame(QSVVPPContext *s, AVFilterLink *outlink) { AVFilterContext *ctx = outlink->src; QSVFrame *out_frame; - int ret; + int i, ret; clear_unused_frames(s->out_frame_list); @@ -374,12 +374,26 @@ static QSVFrame *query_frame(QSVVPPContext *s, AVFilterLink *outlink) out_frame->surface = (mfxFrameSurface1 *)out_frame->frame->data[3]; } else { /* Get a frame with aligned dimensions. - * Libmfx need system memory being 128x64 aligned */ - out_frame->frame = ff_get_video_buffer(outlink, - FFALIGN(outlink->w, 128), - FFALIGN(outlink->h, 64)); - if (!out_frame->frame) + * Libmfx need system memory being 128x64 aligned + * and continuously allocated across Y and UV */ + out_frame->frame = av_frame_alloc(); + if (!out_frame->frame) { return NULL; + } + + out_frame->frame->width = FFALIGN(outlink->w, 128); + out_frame->frame->height = FFALIGN(outlink->h, 64); + out_frame->frame->format = outlink->format; + + ret = av_frame_get_buffer(out_frame->frame, 128); + if (ret < 0) + return NULL; + + /* remove plane_padding introduced by av_frame_get_buffer */ + for (i = 1; i < 4; i++) { + if (out_frame->frame->data[i]) + out_frame->frame->data[i] -= i * 128; + } out_frame->frame->width = outlink->w; out_frame->frame->height = outlink->h;