From patchwork Tue Sep 18 22:30:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 10366 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp11907jap; Tue, 18 Sep 2018 15:32:58 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdb81rQ1vYBSNB92Z8slsMK+K9EunzYfE6Eng/LHmYP09/TH1YokGS2NPoASXUqeDY7Amp3J X-Received: by 2002:adf:a299:: with SMTP id s25-v6mr1386894wra.100.1537309978109; Tue, 18 Sep 2018 15:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537309978; cv=none; d=google.com; s=arc-20160816; b=oD29mOyTQ8EghICFur+VsID04pGmffGXFuixXxE8TAHffFO6FIHgMed4jyU+rG9Bcr Lw5M/ydjEiisupwGojENPBRAAvXxzn15bcrNi5F/8Ub3X4LU5gQLf789m+Olt0r10aCa sRXw2kIEN3lXKyOTa2DN41vVAwT8xn5Dy63tS64zsZI0XPv3Cb048O7WJ0RJyU1vNsfU 39y9cfvtCTWGp09Du6vhQfPEOX9h1qwen6f0tnzEtTIRGb0LAbaPFR0ek5e3+o0mT4xx kfPmn0FdYefehTaYKY83pBd46OeZ8KDvq0eauQIKVsSEYJ7FfEIIqeIPEQEMrHLgbiiV 6zUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=BbiHY21NSOAh2xtiMW1mz+/C43caUiZ7oz3YfnO+zEg=; b=LfnbJhPZrz+pMRmTD8TDFW2j3BcgSE+8+Sb3Kclec9eaxoDmZ8a2R9+RbdSdqkT3aa X9ifY0kp74RcSH+zM4wQweMpvBtlHB8aZOLcSaAwx4OZ6SLc9V+BZkF61bROg6OfjviS jsR3PEThQqpP4v964B3bM6UpeH75yWS4mNBsvLxTE+67Sz+sZCzBp2SU5flqoKOnvwAr 2OsKuQ2MKlzP/vBGvOuF4U+bS2C+L9OcOTU+o2+jOkMCRTEgjlN/5x092k/PZuqMrH39 bB5no27rFfaGeM97mciy7PiT3KaOBGvXDYDfnXZ7acudAd4nOIFnKYks9u76v1d5S3Jb bItA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@jkqxz-net.20150623.gappssmtp.com header.s=20150623 header.b=jXyu23j1; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j66-v6si409352wrj.130.2018.09.18.15.32.57; Tue, 18 Sep 2018 15:32:58 -0700 (PDT) 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=@jkqxz-net.20150623.gappssmtp.com header.s=20150623 header.b=jXyu23j1; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6D07F68A4B0; Wed, 19 Sep 2018 01:31:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 40C4068A23A for ; Wed, 19 Sep 2018 01:31:19 +0300 (EEST) Received: by mail-wm1-f51.google.com with SMTP id n11-v6so4605310wmc.2 for ; Tue, 18 Sep 2018 15:31:33 -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; bh=PsANNC4Iua2Ss47hMpH6vsNgads/c2tePFu0Hz+M5Q8=; b=jXyu23j1v5a0obrYKLbwcCe+ca6VLYn3GffUwTANtdeD8f0Osi55nUVUlSaz8K/cWK tEvi0KfhefUaeGN+ckEAivudnfd9n5gDgKixsdyYLOhqK8kH88l9JzloyFkboMoTofAw Tgo8gX0Pc4f8oKSX6FPmUypBkU6mtRGs0+nlCbAxRoairdqNl5BzTno49Ws6555YvOCJ z5dm3rr1IvXBxUSobwnCGK/O9LGeFHAxbv+P/wmTg47wrLU18rbK3ISgVbg4FZoNvxac sqGIXLeYVMGhaZz9JK3rFD0d5yneZqi1QtrjUTSLV4wK58Cg7UdmBZqj9ssUj8f36Lpn 8QOw== 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; bh=PsANNC4Iua2Ss47hMpH6vsNgads/c2tePFu0Hz+M5Q8=; b=bnxEd03IGOsNh5dPpTankPaqct3bAQsE1IXEuCWcmNQEdu48HR9XVBywbqS02ELfov Hiw07AosEH4zeEnkKt2ED6qMCwypq7Wk/UbVXsCnchIGwdtWx3xLnJSHPdpLHGDnAMuR zWvR2sul6lkzJUdbVVAhi1SNv6p9jbuTGUPhRQiScK+7EwTyYTap6YS4LJNoDFtG3ePP QGRlLfUzVwoaltDBUofAD1N5ldl8gVBG0Vy+2fb90mPaosbLFYDaynU5ZweOy4jy1rZy IXdTcjW4eUVgvElJNMvTGms83riGwKGi2zRSR80zOUr9MCS7Y8NWrFGVoT3sAEwxUFbe qz9A== X-Gm-Message-State: APzg51BytDsuIpOAv9E2v7V6V7g1971pOiWBIzquHd7suQsz3d09RLx2 HD1OEmJC6FgulEUtO13VsyLc666mBXw= X-Received: by 2002:a1c:2787:: with SMTP id n129-v6mr16411210wmn.101.1537309892464; Tue, 18 Sep 2018 15:31:32 -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 e141-v6sm4863826wmd.32.2018.09.18.15.31.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Sep 2018 15:31:31 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Tue, 18 Sep 2018 23:30:49 +0100 Message-Id: <20180918223116.14322-12-sw@jkqxz.net> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180918223116.14322-1-sw@jkqxz.net> References: <20180918223116.14322-1-sw@jkqxz.net> Subject: [FFmpeg-devel] [PATCH v4 11/38] vaapi_encode_h264: Properly set constraint flags 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" constraint_set1_flag should be set for constrained baseline and main profiles, because the stream conforms to main profile. constraint_set3_flag should be set for high profile when the stream is intra-only. constraint_set4_flag should always be set for main and high profiles because interlaced encoding is not supported. constraint_set5_flag should be set for main and high profiles when B-frames are not used. Also fix the setting of max_num_ref_frames - use the gop_size value to check for intra-only rather than the constraint flag (which is not necessarily set). --- libavcodec/vaapi_encode_h264.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c index b233a91d04..bba6848f03 100644 --- a/libavcodec/vaapi_encode_h264.c +++ b/libavcodec/vaapi_encode_h264.c @@ -305,10 +305,19 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) sps->nal_unit_header.nal_unit_type = H264_NAL_SPS; sps->profile_idc = avctx->profile & 0xff; - sps->constraint_set1_flag = - !!(avctx->profile & FF_PROFILE_H264_CONSTRAINED); - sps->constraint_set3_flag = - !!(avctx->profile & FF_PROFILE_H264_INTRA); + + if (avctx->profile == FF_PROFILE_H264_CONSTRAINED_BASELINE || + avctx->profile == FF_PROFILE_H264_MAIN) + sps->constraint_set1_flag = 1; + + if (avctx->profile == FF_PROFILE_H264_HIGH) + sps->constraint_set3_flag = ctx->gop_size == 1; + + if (avctx->profile == FF_PROFILE_H264_MAIN || + avctx->profile == FF_PROFILE_H264_HIGH) { + sps->constraint_set4_flag = 1; + sps->constraint_set5_flag = ctx->b_per_p == 0; + } sps->level_idc = avctx->level; @@ -321,8 +330,7 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx) av_clip(av_log2(ctx->b_per_p + 1) - 2, 0, 12); sps->max_num_ref_frames = - (avctx->profile & FF_PROFILE_H264_INTRA) ? 0 : - 1 + (ctx->b_per_p > 0); + ctx->gop_size == 1 ? 0 : 1 + (ctx->b_per_p > 0); sps->pic_width_in_mbs_minus1 = priv->mb_width - 1; sps->pic_height_in_map_units_minus1 = priv->mb_height - 1;