From patchwork Wed Nov 30 02:20:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 1611 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.65.86 with SMTP id o83csp137614vsa; Tue, 29 Nov 2016 18:21:09 -0800 (PST) X-Received: by 10.28.18.194 with SMTP id 185mr25420418wms.124.1480472469674; Tue, 29 Nov 2016 18:21:09 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sm3si61785885wjc.199.2016.11.29.18.21.08; Tue, 29 Nov 2016 18:21:09 -0800 (PST) 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 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 3BD34689E72; Wed, 30 Nov 2016 04:21:00 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C5C99689895 for ; Wed, 30 Nov 2016 04:20:53 +0200 (EET) Received: by mail-pf0-f194.google.com with SMTP id i88so9188880pfk.2 for ; Tue, 29 Nov 2016 18:21:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=to:from:subject:message-id:date:user-agent:mime-version; bh=ETeKuNB2MWjfTqQH+NLWCA51c4w07Qjs9PqpSnEQ260=; b=SwxjCAoCoAH1bW26rZq74gNlvuFpqBW2R6hd1VD0njwp/oVbKddh2aLZ2F3UJ9nbke algbv2QEtsmMGHVsvOUj5XuM+stxOZeHI31BZRv/IUs5Qz17WgW+QIhWGC7wZVLTRZu2 bNoeYvNB+bX57lWltE7jg+gz2/xavcSS0Cf9hFmfuVzGiUGyvw7QBdgNrvudm8hX4jqU akmsoViuqkCntrSKDyA6gSFg5CfRocGPd4PLLvft9GjQA85vxZadYNKgEEE1rrO0dxyJ a/KSWzKj7rxmXuDAk0TnzYBECN77YSASFEe3FuIi89Mk14GNpzFjoMWXCKTYAk+NMbAX fH7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version; bh=ETeKuNB2MWjfTqQH+NLWCA51c4w07Qjs9PqpSnEQ260=; b=j+FeTemdSx0ld9w/IiIpJ3w6WCWIxAg1fci9BbW50NyV/ih6oWURK/Y6y1Eh8dKktj Js+6cI2aFcFwIe3GTqDrtx8Ko5qCefHP1IlzBc1Hnm+QwkuQ+55fe6AmeUvlZ80fWAHc 1ejPSU7yOyAmE7ifAXCavGqAryk4EdaDEg+rTyezwPd39okI/+daVd1tvu2Xny9+RebL NhrOxejUd2Zp4fRYE7WZIV4rhjDIMmP+0DmTWjYv13FNLQq/5Mb4pevO9gLeTf5A8OQk uIloWHcwTc8y7GpFjHNIv5+7zvFmaDKZt5/4+L0JrKnmTMGwr1zuIHwPPmfadlW14Ipv mjXQ== X-Gm-Message-State: AKaTC03W43HxDw0Vdiw6M7qD8DCNkO4bVyAi8oCQbryBAZ8PQZKTJpQ7i/SD4tX1mmLVng== X-Received: by 10.98.220.157 with SMTP id c29mr30846436pfl.29.1480472458516; Tue, 29 Nov 2016 18:20:58 -0800 (PST) Received: from [10.239.204.206] ([192.55.54.40]) by smtp.gmail.com with ESMTPSA id y134sm97922354pfg.81.2016.11.29.18.20.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 18:20:57 -0800 (PST) To: FFmpeg development discussions and patches , Mark Thompson , mypopy@gmail.com, Yi Wang From: Jun Zhao Message-ID: <6fc5c751-fe57-f1da-b793-f6f130472608@gmail.com> Date: Wed, 30 Nov 2016 10:20:54 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0 MIME-Version: 1.0 Content-Disposition: attachment; filename*0="0001-lavc-vaapi_h26-45-add-crop-info-support-in-vaapi_h26.pa"; filename*1="tch" X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH] lavc/vaapi_h26[45]: add crop info support in vaapi_h26[4, 5] 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From 20bedd18213420c77d5e8a26fbe741d8d204ac10 Mon Sep 17 00:00:00 2001 From: Jun Zhao Date: Tue, 29 Nov 2016 14:14:25 +0800 Subject: [PATCH] lavc/vaapi_h26[45]: add crop info support in vaapi_h26[4,5] add crop information support in vaapi_h26[4,5] hwaccel decode, and align h264/hevc software decoder. After this fix, FATE test h264-conformance-cvfc1_sony_c/hevc-conformance-CONFWIN_A_Sony_1 will pass in i965/SKL. Signed-off-by: Wang, Yi A Signed-off-by: Jun Zhao --- libavcodec/h264dec.c | 13 +++++++++++++ libavcodec/hevc_refs.c | 7 +++++++ libavutil/hwcontext.h | 6 ++++++ libavutil/hwcontext_vaapi.c | 1 + 4 files changed, 27 insertions(+) diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c index ed0b724..2e7692c 100644 --- a/libavcodec/h264dec.c +++ b/libavcodec/h264dec.c @@ -54,6 +54,7 @@ #include "rectangle.h" #include "thread.h" #include "vdpau_compat.h" +#include "libavutil/hwcontext.h" static int h264_decode_end(AVCodecContext *avctx); @@ -1012,6 +1013,18 @@ static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp) (srcp->crop_top >> vshift) * dst->linesize[i]; dst->data[i] += off; } + + /* HWAccel always used data[0-3] in avframe */ + for (i = 0; i < 3; i++) { + if (dst->hw_frames_ctx) { + int hshift = (i > 0) ? desc->log2_chroma_w : 0; + int vshift = (i > 0) ? desc->log2_chroma_h : 0; + AVHWFramesContext *ctx = (AVHWFramesContext*)dst->hw_frames_ctx->data; + ctx->top_offset[i] = srcp->crop_top >> vshift; + ctx->left_offset[i] = (srcp->crop_left >> hshift) << h->pixel_shift; + } + } + return 0; } diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index 611ad45..a184de2 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -28,6 +28,7 @@ #include "thread.h" #include "hevc.h" +#include "libavutil/hwcontext.h" void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags) { /* frame->frame can be NULL if context init failed */ @@ -222,7 +223,13 @@ int ff_hevc_output_frame(HEVCContext *s, AVFrame *out, int flush) int off = ((frame->window.left_offset >> hshift) << pixel_shift) + (frame->window.top_offset >> vshift) * dst->linesize[i]; dst->data[i] += off; + if (out->hw_frames_ctx) { + AVHWFramesContext *ctx = (AVHWFramesContext*)out->hw_frames_ctx->data; + ctx->top_offset[i] = frame->window.top_offset >> vshift; + ctx->left_offset[i] = (frame->window.left_offset >> hshift) << pixel_shift; + } } + av_log(s->avctx, AV_LOG_DEBUG, "Output frame with POC %d.\n", frame->poc); return 1; diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h index 785da09..0d666c3 100644 --- a/libavutil/hwcontext.h +++ b/libavutil/hwcontext.h @@ -220,6 +220,12 @@ typedef struct AVHWFramesContext { * Must be set by the user before calling av_hwframe_ctx_init(). */ int width, height; + + /** + * The top and left offset of the frames + */ + int top_offset[AV_NUM_DATA_POINTERS]; + int left_offset[AV_NUM_DATA_POINTERS]; } AVHWFramesContext; /** diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index 6176bdc..fa026cc 100644 --- a/libavutil/hwcontext_vaapi.c +++ b/libavutil/hwcontext_vaapi.c @@ -781,6 +781,7 @@ static int vaapi_map_frame(AVHWFramesContext *hwfc, for (i = 0; i < map->image.num_planes; i++) { dst->data[i] = (uint8_t*)address + map->image.offsets[i]; dst->linesize[i] = map->image.pitches[i]; + dst->data[i] += hwfc->top_offset[i] * dst->linesize[i] + hwfc->left_offset[i]; } if ( #ifdef VA_FOURCC_YV16