From patchwork Tue Jan 3 06:35:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Huang, Zhengxu" X-Patchwork-Id: 2029 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp4243751vsb; Mon, 2 Jan 2017 22:43:59 -0800 (PST) X-Received: by 10.194.60.195 with SMTP id j3mr54360016wjr.149.1483425839721; Mon, 02 Jan 2017 22:43:59 -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 w63si72354881wmb.92.2017.01.02.22.43.58; Mon, 02 Jan 2017 22:43:59 -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 54F316897C1; Tue, 3 Jan 2017 08:43:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AC6CE680780 for ; Tue, 3 Jan 2017 08:43:45 +0200 (EET) Received: by mail-pg0-f67.google.com with SMTP id g1so32596965pgn.0 for ; Mon, 02 Jan 2017 22:43:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=to:from:cc:subject:message-id:date:user-agent:mime-version; bh=ihKGcVuOYU+N3Yo1Almg+T4U/aEeqjCZSZD/MNcEm6M=; b=ZQAA29IDwgMrx25PMsgTTAL7i5KUs1oOw4fUk+ry49aHOX3JsHRL/nahzx7229eIKR xmtr8GdXtC37sELMdWf2OjT6JXUALbv4CqdTRN/4IJxyhm46XJBgbhGYycJ2LfSb7+SK PDyc1/o5V1zrG0B8DJhf/POyn5qAa64THAtxfSTK6NnIbHC1VL2J74PxmhgBnfYOCYP6 ncPOTq/ItvrhXIq9TvC7in0x4bt7e7ShhRX2epJH3gsoPF1LNopu1EOf8mZW1OMtHAz4 Ytd5OhLATD8NBs/RsmTtAEnWxHEznvMGwASQCQegeV1RxLSnitNIlmJ9bOJoAURYxxeM 5vNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:cc:subject:message-id:date:user-agent :mime-version; bh=ihKGcVuOYU+N3Yo1Almg+T4U/aEeqjCZSZD/MNcEm6M=; b=GSNMamUTUAECzGRFqPUt8ACDY2pnKDLJOe4RdebwlQ9P71BwqwgHFAvxAd+/JSkaNA PdbsqDSr2HlajhxLlweGyJftNOg8ozrcEWNZGp9FZwn9gPQQyTL08Ffymn6g7k5QCHOa tKNRgQnHnunK5FGVQVvWyKHBxdyU7JrA7K+5F21lUXvWMveiWfkf9Dcpwu3z7HPkZf1c kqelWhcgV7oASfhKHmiex/yldaDYqREdeU68wRv6lvkkaTS+2LIXi0UOiJvimroAsqaH Ie4UPgB7hBhgBtBXEvSu2SRus4Ner6iNPlkzOYBRK14iTupTGytar6CBujTsXUZ8pzYh 5Dtw== X-Gm-Message-State: AIkVDXJt3xL/4yhKNn7xJDQmSdGvasm24mrxlaoP1TNiZjMlHGttwJ92hx9BHSTxNefjcA== X-Received: by 10.98.50.67 with SMTP id y64mr55862722pfy.98.1483425329514; Mon, 02 Jan 2017 22:35:29 -0800 (PST) Received: from [10.239.205.27] (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by smtp.gmail.com with ESMTPSA id 78sm72451803pfj.23.2017.01.02.22.35.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jan 2017 22:35:29 -0800 (PST) To: sw@jkqxz.net, chaox.a.liu@gmail.com, huazh407@gmail.com From: "Huang, Zhengxu" Message-ID: <2590bfe7-9daf-4316-52e3-2c37f9b2f061@gmail.com> Date: Tue, 3 Jan 2017 14:35:25 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] libavutil/hwcontext_qsv: Fix bug that the QSV encoded frames'width and height are 32-aligned 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: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From 8b1bcc0634f6ce36acfbd2bfdd26690a6323d09c Mon Sep 17 00:00:00 2001 From: Zhengxu Date: Fri, 16 Dec 2016 11:10:34 +0800 Subject: [PATCH] libavutil/hwcontext_qsv: Fix bug that the QSV encoded frames' width and height are 32-aligned. Description: If an input is of 1280x720, the encoded stream created by command below is of 1280x736: ffmpeg -hwaccel qsv -c:v h264_qsv -i test.h264 -c:v h264_qsv out.h264 Reason: When creating a AVQSVFramesContext, width and height shouldn't be aligned, or the mfxSurfaces' cropW and cropH will be wrong. Fix: User should configure AVQSVFramesContext with origin width and height and AVFramesContext will align the width and height when being initiallized. Signed-off-by: ChaoX A Liu Signed-off-by: Huang, Zhengxu Signed-off-by: Andrew, Zhang --- ffmpeg_qsv.c | 8 ++++---- libavutil/hwcontext_qsv.c | 8 ++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ffmpeg_qsv.c b/ffmpeg_qsv.c index 68ff5bd..aab7375 100644 --- a/ffmpeg_qsv.c +++ b/ffmpeg_qsv.c @@ -76,8 +76,8 @@ int qsv_init(AVCodecContext *s) frames_ctx = (AVHWFramesContext*)ist->hw_frames_ctx->data; frames_hwctx = frames_ctx->hwctx; - frames_ctx->width = FFALIGN(s->coded_width, 32); - frames_ctx->height = FFALIGN(s->coded_height, 32); + frames_ctx->width = s->coded_width; + frames_ctx->height = s->coded_height; frames_ctx->format = AV_PIX_FMT_QSV; frames_ctx->sw_format = s->sw_pix_fmt; frames_ctx->initial_pool_size = 64; @@ -152,8 +152,8 @@ int qsv_transcode_init(OutputStream *ost) encode_frames = (AVHWFramesContext*)encode_frames_ref->data; qsv_frames = encode_frames->hwctx; - encode_frames->width = FFALIGN(ist->resample_width, 32); - encode_frames->height = FFALIGN(ist->resample_height, 32); + encode_frames->width = ist->resample_width; + encode_frames->height = ist->resample_height; encode_frames->format = AV_PIX_FMT_QSV; encode_frames->sw_format = AV_PIX_FMT_NV12; encode_frames->initial_pool_size = 1; diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index 03244a6..2dc9aca 100644 --- a/libavutil/hwcontext_qsv.c +++ b/libavutil/hwcontext_qsv.c @@ -308,9 +308,13 @@ static int qsv_init_pool(AVHWFramesContext *ctx, uint32_t fourcc) surf->Info.ChromaFormat = MFX_CHROMAFORMAT_YUV444; surf->Info.FourCC = fourcc; - surf->Info.Width = ctx->width; + /* + * WxH being aligned with 32x32 is needed by MSDK. + * CropW and CropH are the real size of the frame. + */ + surf->Info.Width = FFALIGN(ctx->width, 32); surf->Info.CropW = ctx->width; - surf->Info.Height = ctx->height; + surf->Info.Height = FFALIGN(ctx->height, 32); surf->Info.CropH = ctx->height; surf->Info.FrameRateExtN = 25; surf->Info.FrameRateExtD = 1;