From patchwork Sat Nov 3 02:52:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jun Zhao X-Patchwork-Id: 10909 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 E0DCA44E056 for ; Sat, 3 Nov 2018 05:00:37 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 621D568A9FB; Sat, 3 Nov 2018 05:00:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F042968A58F for ; Sat, 3 Nov 2018 05:00:02 +0200 (EET) Received: by mail-pl1-f196.google.com with SMTP id p6-v6so1807515pll.4 for ; Fri, 02 Nov 2018 20:00:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=294mm8Yjr8JlVU+Q49IJSgvexc/VfRXOW7T+Kr7ptxU=; b=KTJ3RAOpq1deGiwvEEfiYnci67QszbG6V0H9TL0nyq2ptB/ZdNnHp/gcBQEa1kYHTI 3KRV6IKobrsChnMAzZL7tfZCYP0uR9AscFKHwPP5RkFlRZ0XrguucB+Nm97rMxhXgVn5 EfkRlr1V2EjW/Vy6cOGMJc8RDuGnd+fcFlWKcMEboM/YP77X+tkExob+NHOC1qa8XQB7 prxeAr8FGD4nv3W7HbCA2ppM7581bDN81niwDcq9EKRyHtvfV5dpJZusT4R0GZITihOj cWEsScSlS28Rs7IMK8ylFWuto0JZFbDx1wMbsqf0bDjNLfYOmP+xptp8wHxi/UcxT3Tu s6wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=294mm8Yjr8JlVU+Q49IJSgvexc/VfRXOW7T+Kr7ptxU=; b=dphtH2oH4HKKpeab0VeKhToSXOY2z0K0DXgGDDF85PccVxCt/RSv6d3Skgwp0ORjmV pf105KBnURQbh+UDblhJY9yRdfDMlnQ+Qh/lSWew4JK6zAtDv1wu0I40q1MScuNtQNbo mbO/GzvPIgMF5RpR3uxZZxc02Egapd3oZMT5pkJa7DbRY+iyY6gLcRcL3X9SCJWQXbZZ KCTsLp2o/mncr6UaqfTOBZ7qZNEmjWjoTt+3WnzLv2Ylnj/CcS9yKrxT7JJP5EcXHGrE t1/dDz1hkPphCP245sKd30EtNmJtMfRoLwdmIobB71N4qb0X/qHZjaatTfJNgmAMeep/ YZ+g== X-Gm-Message-State: AGRZ1gKZ5JdoDkna/T//p3oz5rIJ5afY6MK7lSF7fFiyvsOLcctTRf8n s2vYIpeN/3Hb+VfmPxIkaSnzKzRy X-Google-Smtp-Source: AJdET5e0jz5VmkgKLzjsPU27JIO0CH8wuCJcjVZBMCtq4MdsTe/v4OFgBglywW8F042oldHQn2iP6A== X-Received: by 2002:a17:902:f209:: with SMTP id gn9mr13385626plb.6.1541213546056; Fri, 02 Nov 2018 19:52:26 -0700 (PDT) Received: from localhost.localdomain ([47.90.47.25]) by smtp.gmail.com with ESMTPSA id e127-v6sm33803195pfe.142.2018.11.02.19.52.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 19:52:25 -0700 (PDT) From: Jun Zhao To: ffmpeg-devel@ffmpeg.org Date: Sat, 3 Nov 2018 10:52:06 +0800 Message-Id: <1541213532-23882-2-git-send-email-mypopydev@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1541213532-23882-1-git-send-email-mypopydev@gmail.com> References: <1541213532-23882-1-git-send-email-mypopydev@gmail.com> Subject: [FFmpeg-devel] [PATCH 1/7] lavc/vaapi_encode: Add codec-specific bit rate control callback. 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: Jun Zhao , Jun Zhao MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Add extra codec-specific bit rate control configuration callback interface. Signed-off-by: Jun Zhao --- libavcodec/vaapi_encode.c | 9 +++++++++ libavcodec/vaapi_encode.h | 3 +++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index 2fe8501..0e7f0a1 100644 --- a/libavcodec/vaapi_encode.c +++ b/libavcodec/vaapi_encode.c @@ -1261,6 +1261,7 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) int fr_num, fr_den; VAConfigAttrib rc_attr = { VAConfigAttribRateControl }; VAStatus vas; + int err; vas = vaGetConfigAttributes(ctx->hwctx->display, ctx->va_profile, ctx->va_entrypoint, @@ -1412,6 +1413,14 @@ static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx) .max_qp = (avctx->qmax > 0 ? avctx->qmax : 0), #endif }; + if (ctx->codec->bit_rate_control) { + err = ctx->codec->bit_rate_control(avctx); + if (err < 0) { + av_log(avctx, AV_LOG_ERROR, "Codec specific bit rate control setting " + "failed: %d.\n", err); + return err; + } + } vaapi_encode_add_global_param(avctx, &ctx->rc_params.misc, sizeof(ctx->rc_params)); diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h index 965fe65..c40de65 100644 --- a/libavcodec/vaapi_encode.h +++ b/libavcodec/vaapi_encode.h @@ -268,6 +268,9 @@ typedef struct VAAPIEncodeType { // add any necessary global parameters). int (*configure)(AVCodecContext *avctx); + // Perform any extra codec-specific bit rate control configuration + int (*bit_rate_control)(AVCodecContext *avctx); + // The size of the parameter structures: // sizeof(VAEnc{type}ParameterBuffer{codec}). size_t sequence_params_size;