From patchwork Wed Aug 22 23:44:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Thompson X-Patchwork-Id: 10068 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:12c4:0:0:0:0:0 with SMTP id 65-v6csp1441134jap; Wed, 22 Aug 2018 16:46:27 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZLJ4HP9ceFBSJQJbAvdfpB9ed0mgZAHv80ACDB84YMXdxMXzYdjM+xpH2jmrWVn3AAvvca X-Received: by 2002:a1c:3a8f:: with SMTP id h137-v6mr3648401wma.72.1534981587224; Wed, 22 Aug 2018 16:46:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534981587; cv=none; d=google.com; s=arc-20160816; b=hCI6NOjavcQS9IxDWuUgzg0gDQSrPpiwvQHqtIgD4UeipyuFiUBhRHMId2XWbiqv3U a7k89hZARBUT25fubVaNinJ1rdTZf+utElj830xpKJr70mLhr4+tz7IGpoTHWOMnEpVy +Db4EOR7vrTwcQQ3UI62cgswx03T+jK/3rP/kaWETJoLr4yQsKAg7rtdEgP7jWRUTgHz g3qAR+eYpLBNRU3eMkg7ze5hIuNqg80B0jHMTQsbtxxsiJdEkzqC0YGCR7atLagX5L6I 0GlSLpjJE8iiAbHSW2Q3Jcu7O62P+AY6sOz15pC2xWuGYHIdTdBn3BFUNyOWW5TbILFI bpeg== 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=HU7lMhwTMchB6q9gmrPcsR8Y+onUb9+kJGJ9V1w75Is=; b=BK7+GCOxwRI8KyMW9RH578K6UFm9ICrZ7iLC/Pn8CQEF1v88DymuseqTebzSOMIklN 7Uv308K6VPPk+2QqsLRe3n7W+ESPLiZF8YlqvBOmOin38sthHxMFPDHof7ulQ1BDMFwE pMPbPMLQUvN6UK5349LLvgg4Hd5IXDeFZ2dux55HyiZ9uW91SL4RnZwa6C31yuktBuj5 OAmfp/GdHZIeLBsHTDvtwYIYhZAJynxCd9RgeRV8SFCz7HW4mRVhAfmXrbaxCzIkdD7h adsx/l1gQmfjhJyDBd1/GCtZYxNK66eLs+/pNhqPXuz0KqdEiiJA1d/Q0ZeXDQdYVVXc 7i3A== 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=ckuCPka5; 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 r131-v6si2265399wmb.2.2018.08.22.16.46.26; Wed, 22 Aug 2018 16:46:27 -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=ckuCPka5; 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 A8F6F689CCD; Thu, 23 Aug 2018 02:45:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f53.google.com (mail-wm0-f53.google.com [74.125.82.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C279E689C39 for ; Thu, 23 Aug 2018 02:45:25 +0300 (EEST) Received: by mail-wm0-f53.google.com with SMTP id o18-v6so3892124wmc.0 for ; Wed, 22 Aug 2018 16:45:27 -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=0ZqhZQrHo4tvHQEh8mW+kViZoR7JLyZCSO+4nIGIL/0=; b=ckuCPka5mkBvPyq0Ldhndq+shYToCSZeLKM3MH+qqMeH4eFZQ4WnqSGrcAMS5MhZq3 tGJL36khH0PBE9aYLSbyVm+fFGwtBLIuKCY24+zyfYr4wGXP+Hb97IzC60sU8clVaYDV M1FUQRaslu+Uv3nWhwhq5lPckw12V+SCH+qs41oeAtr5sm73uq398cq70oUZ1qpQqhSC BCOhuDGfbUz/GucAV0/W3FPdhIOoGtZLSdNcvVQgiHEcpGrhErfkEZzXPlugIwIDijqS niFyU+DeRqCCpNqmw29MbUuFK9B48rT/2owPRH5U1ajy9nYXVU9OU66HW5PTnuIAiUI+ NMow== 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=0ZqhZQrHo4tvHQEh8mW+kViZoR7JLyZCSO+4nIGIL/0=; b=C9PZcagmj6reasYR7F0Dx0KIA+piBcvqzIvs4vycNjYDrUncdPy1W87tcDpOtcMjZ8 R8Ww9zbYaHh5zmOSYJsnIrvYccA6oosK8oiF7UD/ToK3geY/eVrDGn4NYdEnyk5Lznmk ca5WLQjvwXUB7zGATbYlU2RHAApbrr3XUOg6lMVdz83KYm7A16b5BDOJ073Djj+NJtx8 vy4DwptNhLX6WdfMYLjPq4y0TsQq7bv6GCyKCnz+MwErWUj/J8YUo12dRgg2C8s4I3Qp PvKXn62w9HiisWsROakb+iCVHD3/2UkhSc7D7+BxhTTSwJIkrCIXLb2eMdmM1EcQIl5u jr5w== X-Gm-Message-State: APzg51Dlo8K6RG5ILyocdmuSukQt8QJHNYmmakn07GdDyfVXbwpD/cvd aaZ1miGMfgOY4sb3tZN6GPNMuCVphZA= X-Received: by 2002:a1c:92:: with SMTP id 140-v6mr3332697wma.87.1534981526446; Wed, 22 Aug 2018 16:45:26 -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 x82-v6sm8184537wmd.11.2018.08.22.16.45.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Aug 2018 16:45:25 -0700 (PDT) From: Mark Thompson To: ffmpeg-devel@ffmpeg.org Date: Thu, 23 Aug 2018 00:44:39 +0100 Message-Id: <20180822234514.10571-7-sw@jkqxz.net> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180822234514.10571-1-sw@jkqxz.net> References: <20180822234514.10571-1-sw@jkqxz.net> Subject: [FFmpeg-devel] [PATCH v3 06/41] vaapi_encode_vp9: Move options and common structures into context 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" --- libavcodec/vaapi_encode_vp9.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/libavcodec/vaapi_encode_vp9.c b/libavcodec/vaapi_encode_vp9.c index 9108699ac3..6e62213bc9 100644 --- a/libavcodec/vaapi_encode_vp9.c +++ b/libavcodec/vaapi_encode_vp9.c @@ -33,21 +33,25 @@ typedef struct VAAPIEncodeVP9Context { + VAAPIEncodeContext common; + + // User options. + int loop_filter_level; + int loop_filter_sharpness; + + // Derived settings. int q_idx_idr; int q_idx_p; int q_idx_b; + // Stream state. + // Reference direction for B-like frames: // 0 - most recent P/IDR frame is last. // 1 - most recent P frame is golden. int last_ref_dir; } VAAPIEncodeVP9Context; -typedef struct VAAPIEncodeVP9Options { - int loop_filter_level; - int loop_filter_sharpness; -} VAAPIEncodeVP9Options; - #define vseq_var(name) vseq->name, name #define vseq_field(name) vseq->seq_fields.bits.name, name @@ -82,10 +86,8 @@ static int vaapi_encode_vp9_init_sequence_params(AVCodecContext *avctx) static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx, VAAPIEncodePicture *pic) { - VAAPIEncodeContext *ctx = avctx->priv_data; + VAAPIEncodeVP9Context *priv = avctx->priv_data; VAEncPictureParameterBufferVP9 *vpic = pic->codec_picture_params; - VAAPIEncodeVP9Context *priv = ctx->priv_data; - VAAPIEncodeVP9Options *opt = ctx->codec_options; int i; vpic->reconstructed_frame = pic->recon_surface; @@ -169,8 +171,8 @@ static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx, vpic->chroma_ac_qindex_delta = 0; vpic->chroma_dc_qindex_delta = 0; - vpic->filter_level = opt->loop_filter_level; - vpic->sharpness_level = opt->loop_filter_sharpness; + vpic->filter_level = priv->loop_filter_level; + vpic->sharpness_level = priv->loop_filter_sharpness; if (avctx->max_b_frames > 0 && pic->type == PICTURE_TYPE_P) priv->last_ref_dir = !priv->last_ref_dir; @@ -180,8 +182,7 @@ static int vaapi_encode_vp9_init_picture_params(AVCodecContext *avctx, static av_cold int vaapi_encode_vp9_configure(AVCodecContext *avctx) { - VAAPIEncodeContext *ctx = avctx->priv_data; - VAAPIEncodeVP9Context *priv = ctx->priv_data; + VAAPIEncodeVP9Context *priv = avctx->priv_data; priv->q_idx_p = av_clip(avctx->global_quality, 0, VP9_MAX_QUANT); if (avctx->i_quant_factor > 0.0) @@ -266,8 +267,7 @@ static av_cold int vaapi_encode_vp9_init(AVCodecContext *avctx) return ff_vaapi_encode_init(avctx); } -#define OFFSET(x) (offsetof(VAAPIEncodeContext, codec_options_data) + \ - offsetof(VAAPIEncodeVP9Options, x)) +#define OFFSET(x) offsetof(VAAPIEncodeVP9Context, x) #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM) static const AVOption vaapi_encode_vp9_options[] = { { "loop_filter_level", "Loop filter level", @@ -298,8 +298,7 @@ AVCodec ff_vp9_vaapi_encoder = { .long_name = NULL_IF_CONFIG_SMALL("VP9 (VAAPI)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP9, - .priv_data_size = (sizeof(VAAPIEncodeContext) + - sizeof(VAAPIEncodeVP9Options)), + .priv_data_size = sizeof(VAAPIEncodeVP9Context), .init = &vaapi_encode_vp9_init, .encode2 = &ff_vaapi_encode2, .close = &ff_vaapi_encode_close,