From patchwork Tue Apr 9 22:07:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 12672 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 4529E448A83 for ; Wed, 10 Apr 2019 01:07:55 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3466068AE1D; Wed, 10 Apr 2019 01:07:55 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4661B68AE19 for ; Wed, 10 Apr 2019 01:07:48 +0300 (EEST) Received: by mail-wm1-f65.google.com with SMTP id y197so396419wmd.0 for ; Tue, 09 Apr 2019 15:07:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Oh+9tJLlWTVvG7DwGRD/zoyxo5EmzsPBOHRi+ZpyMaw=; b=bPHyAriRtZQ9Tm1Y3GItLy0u7kgYLfKDfaVb7BIArUuDfBDW3LkN7enHEQhV3Denvo zAuJlGz0nmHXGivOl0YYY2nmFOuRdK+3uSEB6veN9uOnKqiN6mNWkxoR5GmVUb+coJps Lye215synx1/7VSmjB7BFGw8Jvktyhcjv6FHybFYCGGNR+3/7mzHhztXOMHYGXadyl2k 8DnSd9UN1/Xz9e0GST82AbB7xZ4XhVS/wsrIse22I1jzoMLwdG9iDBRXpnu0WTL0g9Yq jzRZ018D29yMT0Bz2K+4CTpkKg0essvlu+uqddeny2lvwMWSG78YrKZc4p9TUlQV98aO XOtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Oh+9tJLlWTVvG7DwGRD/zoyxo5EmzsPBOHRi+ZpyMaw=; b=qcjDYUAk4fhnCv3T5zgwH5Hc1icnmCT+rJLFIXQwYkrfzORc2VbCWyGHa8vGRLMd6x NhnzsHhKDLnhOT2Hotx6ClLLw/Q9gvUlLFy3RsfRps6kYVx8BgevlH1DdrSxqKcDocHK LA/UU8GFMhgRj9GYV6LeapuYCIBr/X8q6lFJAx87nF6a5YwPh+yuWBqvtBXoY+nc9Hmb sCAq5LtHQNImGBdivTte9XYQiuAjainVnKM2RFnR4/43voJkiiYBkHLHH4EYJOWrvz4l DsOGwIwR6vykU4hNAG0vKVdxtob7AUA1fcHFP92rXATKOgwFWs1tpFXSHjjJJtu2c40m iqeQ== X-Gm-Message-State: APjAAAX9Wy4DdKEdLeagF4KyNMlbneeQrPgqzOCtwzA7Qg+x2cVMPpV8 DTN80wGVghNR3rKkWHoFasd2dBp3wxw= X-Google-Smtp-Source: APXvYqz3BKlXdiI5WdcMKcbmd/NQrHmGcpook1nZAHt5Xk1Ym9qSUD+gLV70J4qvDggOHDK2eS+NBg== X-Received: by 2002:a1c:9dc8:: with SMTP id g191mr354917wme.132.1554847667530; Tue, 09 Apr 2019 15:07:47 -0700 (PDT) Received: from rywe.jkqxz.net (cpc91242-cmbg18-2-0-cust650.5-4.cable.virginm.net. [82.8.130.139]) by smtp.gmail.com with ESMTPSA id v6sm41224332wrt.56.2019.04.09.15.07.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 15:07:46 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Tue, 9 Apr 2019 23:07:30 +0100 Message-Id: <20190409220730.29311-7-sw@jkqxz.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190409220730.29311-1-sw@jkqxz.net> References: <20190409220730.29311-1-sw@jkqxz.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4 7/7] vaapi_encode: Warn if input has cropping information 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" Cropping is not supported by VAAPI encode. --- On 26/03/2019 10:59, Song, Ruiling wrote:> > And do we need to add warning message against crop information in encoder if user failed to add some vaapi filter after crop? > Seems that vaapi encoder does not encode correctly with crop? That's a good idea :) libavcodec/vaapi_encode.c | 19 +++++++++++++++++++ libavcodec/vaapi_encode.h | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 2dda451882..c3d8944c3c 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -913,6 +913,21 @@ static int vaapi_encode_clear_old(AVCodecContext *avctx) return 0; } +static int vaapi_encode_check_frame(AVCodecContext *avctx, + const AVFrame *frame) +{ + VAAPIEncodeContext *ctx = avctx->priv_data; + + if ((frame->crop_top || frame->crop_bottom || + frame->crop_left || frame->crop_right) && !ctx->crop_warned) { + av_log(avctx, AV_LOG_WARNING, "Cropping information on input " + "frames ignored due to lack of API support.\n"); + ctx->crop_warned = 1; + } + + return 0; +} + int ff_vaapi_encode_send_frame(AVCodecContext *avctx, const AVFrame *frame) { VAAPIEncodeContext *ctx = avctx->priv_data; @@ -923,6 +938,10 @@ int ff_vaapi_encode_send_frame(AVCodecContext *avctx, const AVFrame *frame) av_log(avctx, AV_LOG_DEBUG, "Input frame: %ux%u (%"PRId64").\n", frame->width, frame->height, frame->pts); + err = vaapi_encode_check_frame(avctx, frame); + if (err < 0) + return err; + pic = vaapi_encode_alloc(avctx); if (!pic) return AVERROR(ENOMEM); diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 44a8db566e..12efee2d08 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -314,6 +314,10 @@ typedef struct VAAPIEncodeContext { int idr_counter; int gop_counter; int end_of_stream; + + // The encoder does not support cropping information, so warn about + // it the first time we encounter any nonzero crop fields. + int crop_warned; } VAAPIEncodeContext; enum {