From patchwork Mon Nov 4 07:11:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhong Li X-Patchwork-Id: 16092 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 72F8244774E for ; Mon, 4 Nov 2019 09:12:05 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3776C68AC67; Mon, 4 Nov 2019 09:12:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-m965.mail.126.com (mail-m965.mail.126.com [123.126.96.5]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E768F68AE27 for ; Mon, 4 Nov 2019 09:11:57 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id; bh=eMRduh82Xwidek9scw qWFnRMHAiiYP7W4Uu5ci3FSkc=; b=h50Gm1gu0ca5qV4k1sGNKogRKqaQpmqzDJ +8/mgONV7sDrVI9hEYE/BPnyle+0b0oAyOlrjpVWo59sVcNkF3wi1w5sPAuj84oE 2nHRIaxFTgy1Wd299jUa45maAzRG3KjXXnP7OswoS2fVfpgHuf8U3/V76XGztM+U EUWYMoStg= Received: from localhost.localdomain (unknown [140.205.147.71]) by smtp10 (Coremail) with SMTP id NuRpCgBXgYo2z79d9NrdAg--.98S2; Mon, 04 Nov 2019 15:11:51 +0800 (CST) From: Zhong Li To: ffmpeg-devel@ffmpeg.org Date: Mon, 4 Nov 2019 07:11:38 +0000 Message-Id: <1572851498-39155-1-git-send-email-zhongli_dev@126.com> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: NuRpCgBXgYo2z79d9NrdAg--.98S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxZFy5WF1fXF43Ar4DCry3urg_yoWrWw1kpF n5ZF90gr1DJF1fC3yfGwn5uF15A3WrGF18W39F93yqy34fKF4ktrWqkFyrKF1rXrZ09rWU u34qyFZ3WwnIqFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U2PfLUUUUU= X-Originating-IP: [140.205.147.71] X-CM-SenderInfo: x2kr0wxolbvvby6rjloofrz/1tbiKQBjwFpD+bke7AAAsh Subject: [FFmpeg-devel] [PATCH] lavc/qsvenc: add the missing vp9 file 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: Zhong Li MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" It is missed in commit 3358380 Signed-off-by: Zhong Li --- libavcodec/qsvenc_vp9.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 libavcodec/qsvenc_vp9.c diff --git a/libavcodec/qsvenc_vp9.c b/libavcodec/qsvenc_vp9.c new file mode 100644 index 0000000..9402f80 --- /dev/null +++ b/libavcodec/qsvenc_vp9.c @@ -0,0 +1,113 @@ +/* + * Intel MediaSDK QSV based VP9 encoder + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#include +#include + +#include + +#include "libavutil/common.h" +#include "libavutil/opt.h" + +#include "avcodec.h" +#include "internal.h" +#include "qsv.h" +#include "qsv_internal.h" +#include "qsvenc.h" + +typedef struct QSVVP9EncContext { + AVClass *class; + QSVEncContext qsv; +} QSVVP9EncContext; + +static av_cold int qsv_enc_init(AVCodecContext *avctx) +{ + QSVVP9EncContext *q = avctx->priv_data; + q->qsv.low_power = 1; + + return ff_qsv_enc_init(avctx, &q->qsv); +} + +static int qsv_enc_frame(AVCodecContext *avctx, AVPacket *pkt, + const AVFrame *frame, int *got_packet) +{ + QSVVP9EncContext *q = avctx->priv_data; + + return ff_qsv_encode(avctx, &q->qsv, pkt, frame, got_packet); +} + +static av_cold int qsv_enc_close(AVCodecContext *avctx) +{ + QSVVP9EncContext *q = avctx->priv_data; + + return ff_qsv_enc_close(avctx, &q->qsv); +} + +#define OFFSET(x) offsetof(QSVVP9EncContext, x) +#define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM +static const AVOption options[] = { + QSV_COMMON_OPTS + + { "profile", NULL, OFFSET(qsv.profile), AV_OPT_TYPE_INT, { .i64 = MFX_PROFILE_UNKNOWN }, 0, INT_MAX, VE, "profile" }, + { "unknown", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_UNKNOWN}, INT_MIN, INT_MAX, VE, "profile" }, + { "profile0", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_VP9_0 }, INT_MIN, INT_MAX, VE, "profile" }, + { "profile1", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_VP9_1 }, INT_MIN, INT_MAX, VE, "profile" }, + { "profile2", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_VP9_2 }, INT_MIN, INT_MAX, VE, "profile" }, + { "profile3", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_PROFILE_VP9_3 }, INT_MIN, INT_MAX, VE, "profile" }, + + { NULL }, +}; + +static const AVClass class = { + .class_name = "vp9_qsv encoder", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVCodecDefault qsv_enc_defaults[] = { + { "b", "1M" }, + { "refs", "0" }, + { "g", "250" }, + { "trellis", "-1" }, + { "flags", "+cgop" }, + { NULL }, +}; + +AVCodec ff_vp9_qsv_encoder = { + .name = "vp9_qsv", + .long_name = NULL_IF_CONFIG_SMALL("VP9 video (Intel Quick Sync Video acceleration)"), + .priv_data_size = sizeof(QSVVP9EncContext), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_VP9, + .init = qsv_enc_init, + .encode2 = qsv_enc_frame, + .close = qsv_enc_close, + .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID, + .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, + AV_PIX_FMT_P010, + AV_PIX_FMT_QSV, + AV_PIX_FMT_NONE }, + .priv_class = &class, + .defaults = qsv_enc_defaults, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .wrapper_name = "qsv", +};