From patchwork Thu Jun 7 23:43:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 9308 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp194007jad; Thu, 7 Jun 2018 16:46:24 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI/ifFQuqRSUjeJ/d1CuhVja7y1XfAKL4DD4SDGo4VYX+kYhWgJOeyZlze2En/k5sF/Cd7g X-Received: by 2002:adf:8567:: with SMTP id 94-v6mr3073144wrh.24.1528415184743; Thu, 07 Jun 2018 16:46:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528415184; cv=none; d=google.com; s=arc-20160816; b=knrohxHN9jzp2a4W4FYHMZmWchYdH/YRY37o/97RmgjHNl6a1IgIi7WkXRNcwa9GAj lZjGL7jGaq8WYT21tTFfhiJsG7WtGSdEUuXj6PfRBB+LvGE8iGwpdzOwb+Rs7MTGg2U2 uahW9ubWETOYygq83rSr3cdZGCn9+V4wFgV6MjJTDDzqLTBOG+6zYegLJTKcvW+PbdCW M7JZlwGc9teRm8Zy38vUff1BbSAs3apfWGHKSWtC/A7jxgQPNqQUTBdsmvRhwcsmfIFJ ipPzKsEI2JH4rJvuRpOx/Xf1Ja1FGT9WJgXNXf/9Nua2sJeX/l2+1TYPHgrrGC7zGoY1 3rlQ== 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:arc-authentication-results; bh=7CWnrb+6WB+68h58NeeG2UyRGbZAyWg4AmGUnu0lWU4=; b=JtfKpVSscLDModeTjnLVlqgbgF6hbesGnXX/eSkdFuwLhVY4Prc+oFrZ3qzx5W26aO GbwG18VzrHzB/PUA32u0TLonhUa+jQukuKbxNXj0IH6Z+hxi1uDvr94bD3fCxgct9P9g 6B9NCSZA1oRJUVROHZ4XsujfUyee9s7Sy3CP4AwM0dnJMOT93heZr1b9CsGVYSFtCWkU tQSXI0mxI2s5LuMtsfJ8ixiunrwWfnxbeKDZUPJyGKdaB7kjP+yeaieUKpvxtLqXDds3 FnxPz0H/no2b8hpZYutvqmod0BAGbgIB/zuFFKgA8WocUcyYh7ZPDMNeohCMrlFbh+b5 5vew== 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=B3OUIaoR; 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 w8-v6si11784499wra.235.2018.06.07.16.46.24; Thu, 07 Jun 2018 16:46:24 -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=B3OUIaoR; 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 4D50A68A7F0; Fri, 8 Jun 2018 02:43:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr0-f176.google.com (mail-wr0-f176.google.com [209.85.128.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6125E68A7E8 for ; Fri, 8 Jun 2018 02:43:13 +0300 (EEST) Received: by mail-wr0-f176.google.com with SMTP id d2-v6so11504293wrm.10 for ; Thu, 07 Jun 2018 16:44:01 -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=pnFZ012eekx1EdgtiCvF5GNW3Uk2Q86OZyxPVjyYg40=; b=B3OUIaoRu0y+zyUAuV7+DO7okoOCy9X/JYkX/K2XMCK+xYlGLAVfHYg1n7imhh1mS/ qM6yKTClGSbiu4khSfKeFWPSkX0tbO2rBrbTRdV4VopWO1bOLRKBCjVaKluVXsHEtr3o dbEI0mE4FzFzfUG5yAqiyVJm/HoB5lGljqPNlfmAhFpQV5k0m1CQBp8k5h6pQr4k9dwp L59dCWU5HUrwGhQfKYh53RDLBTKWU3YbmJ2zvhvpfmVnQNIv2y8E+jac8C3yN8cbg/wJ l+k9USCEE9Lb7YVivYqRqLvHa2ZnoMdg2IswlwRcthejt422Qdsz9Wt1ujmNXCuhjFij /4AA== 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=pnFZ012eekx1EdgtiCvF5GNW3Uk2Q86OZyxPVjyYg40=; b=eI1hYwuGgJfv+UgX7gXUqyQNAicggDQenffXEVg/+5I+4amZiSu+9xc8GXB8ppdVt0 eScf5TkFj0zln+sZggMwNqpaG9U8UQftQlDJP9U96dUMoiQWo6k2jXJvT/vMN/67Zbdz CIIP9uSx5IGzmjB4OTRgGJhL8OSJAiMJQu3jbp+LpOL6OqK62QsTasj4HRSlsbzn5n5S r1ank3ILXDZ6h+dZ6Qe3ofscSIv0j4KLdf0XE4JFWSItlyPKhKx6QhZWvFm2OzRNyQ8C rGWfHir1Lyo4jchNHcoE34M0RFpU7yw1sCccalUSuZylsq8+9cP6TrV7B+1ItXKiGGY9 Ooag== X-Gm-Message-State: APt69E395ivD5RifDkdcVKHzK33mOP3qao++PmHyFF9Zx3X5u9ZYfY/W O2e0/ZF4S5qelxQHtNVqaHddzSCN X-Received: by 2002:adf:ac69:: with SMTP id v96-v6mr3077175wrc.5.1528415040352; Thu, 07 Jun 2018 16:44:00 -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 r2-v6sm18640545wrq.55.2018.06.07.16.43.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 16:43:59 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Fri, 8 Jun 2018 00:43:15 +0100 Message-Id: <20180607234331.32139-21-sw@jkqxz.net> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180607234331.32139-1-sw@jkqxz.net> References: <20180607234331.32139-1-sw@jkqxz.net> Subject: [FFmpeg-devel] [PATCH v2 20/36] 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 e2f4f4f2f5..a4594ef9f2 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;