From patchwork Sun May 31 06:27:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Zhang, Guiyong" X-Patchwork-Id: 20034 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 771C5449F63 for ; Sun, 31 May 2020 09:27:17 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 52926688337; Sun, 31 May 2020 09:27:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from shasxm03.verisilicon.com (unknown [101.89.135.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E344F68030F for ; Sun, 31 May 2020 09:27:09 +0300 (EEST) Content-Language: en-US DKIM-Signature: v=1; a=rsa-sha256; d=Verisilicon.com; s=default; c=simple/simple; t=1590906427; h=from:subject:to:date:message-id; bh=XnZ23l+UQyRnDILGRi03Q2Oc7+bj85X7kPOoNLzX8Ck=; b=RBzHDDUp0bo/5vOZMhhi5mThTttxJcQW8m8ZJOwIgCHeOPfcgPAj2IFGP+KHH488UVNyTpbJf1I LLy2HGJkT6X5O/5l68mvKy01G1J2vbB4eIoBGEXv+LVqnKJyns9zb5U/+iNUdXbXFT+5tr5dLkf2H ER6+FMVIHGDlo+SGpWk= Received: from SHASXM03.verisilicon.com ([fe80::938:4dda:a2f9:38aa]) by SHASXM06.verisilicon.com ([fe80::59a8:ce34:dc14:ddda%16]) with mapi id 14.03.0123.003; Sun, 31 May 2020 14:27:06 +0800 From: "Zhang, Guiyong" To: "ffmpeg-devel@ffmpeg.org" Thread-Topic: [PATCH v2 3/8] avcodec/hevcdec: Add hevc VPE HW decoder Thread-Index: AdY3FIFPZL9UOcApQhKy0I0tM9sfIg== Date: Sun, 31 May 2020 06:27:06 +0000 Message-ID: <8847CE4FAA78C048A83C2AE8AA751D2770A5372F@SHASXM03.verisilicon.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.10.25.45] x-tm-as-product-ver: SMEX-11.0.0.4179-8.100.1062-25452.001 x-tm-as-result: No--7.324600-0.000000-31 x-tm-as-user-approved-sender: Yes x-tm-as-user-blocked-sender: No MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: [FFmpeg-devel] [PATCH v2 3/8] avcodec/hevcdec: Add hevc VPE HW decoder 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" This decoder uses VPI(VPE Interface) API and library for hevc decoding. Signed-off-by: Qin.Wang --- configure | 1 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/vpe_hevcdec.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 72 insertions(+) create mode 100755 libavcodec/vpe_hevcdec.c -- 1.8.3.1 diff --git a/configure b/configure index 196842a..129a4ee 100755 --- a/configure +++ b/configure @@ -3081,6 +3081,7 @@ hevc_vaapi_encoder_select="cbs_h265 vaapi_encode" hevc_v4l2m2m_decoder_deps="v4l2_m2m hevc_v4l2_m2m" hevc_v4l2m2m_decoder_select="hevc_mp4toannexb_bsf" hevc_v4l2m2m_encoder_deps="v4l2_m2m hevc_v4l2_m2m" +hevc_vpe_decoder_deps="vpe" mjpeg_cuvid_decoder_deps="cuvid" mjpeg_qsv_decoder_select="qsvdec" mjpeg_qsv_encoder_deps="libmfx" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 0c80880..3193b32 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -762,6 +762,7 @@ OBJS-$(CONFIG_ZLIB_ENCODER) += lclenc.o OBJS-$(CONFIG_ZMBV_DECODER) += zmbv.o OBJS-$(CONFIG_ZMBV_ENCODER) += zmbvenc.o OBJS-$(CONFIG_H264_VPE_DECODER) += vpe_h264dec.o vpe_dec_common.o +OBJS-$(CONFIG_HEVC_VPE_DECODER) += vpe_hevcdec.o vpe_dec_common.o # (AD)PCM decoders/encoders OBJS-$(CONFIG_PCM_ALAW_DECODER) += pcm.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 32f6fd6..ae5a791 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -809,6 +809,7 @@ extern AVCodec ff_vp9_qsv_decoder; extern AVCodec ff_vp9_vaapi_encoder; extern AVCodec ff_vp9_qsv_encoder; extern AVCodec ff_h264_vpe_decoder; +extern AVCodec ff_hevc_vpe_decoder; // The iterate API is not usable with ossfuzz due to the excessive size of binaries created #if CONFIG_OSSFUZZ diff --git a/libavcodec/vpe_hevcdec.c b/libavcodec/vpe_hevcdec.c new file mode 100755 index 0000000..0c5a9df --- /dev/null +++ b/libavcodec/vpe_hevcdec.c @@ -0,0 +1,69 @@ +/* + * Verisilicon VPE HEVC Decoder + * + * 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 "hwconfig.h" +#include "internal.h" +#include "libavutil/pixfmt.h" + +#include "vpe_dec_common.h" + +static av_cold int vpe_hevc_decode_init(AVCodecContext *avctx) +{ + return ff_vpe_decode_init(avctx, HEVCDEC_VPE); +} + +static const AVClass vpe_hevc_decode_class = { + .class_name = "hevcd_vpe", + .item_name = av_default_item_name, + .option = vpe_decode_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +static const AVCodecHWConfigInternal *vpe_hw_configs[] = + { &(const AVCodecHWConfigInternal){ + .public = + { + .pix_fmt = AV_PIX_FMT_VPE, + .methods = AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX | + AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, + .device_type = AV_HWDEVICE_TYPE_VPE, + }, + .hwaccel = NULL, + }, + NULL }; + +AVCodec ff_hevc_vpe_decoder = { + .name = "hevc_vpe", + .long_name = NULL_IF_CONFIG_SMALL("HEVC (VPE VC8000D)"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_HEVC, + .priv_data_size = sizeof(VpeDecCtx), + .init = &vpe_hevc_decode_init, + .receive_frame = &ff_vpe_decode_receive_frame, + .close = &ff_vpe_decode_close, + .priv_class = &vpe_hevc_decode_class, + .capabilities = + AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE | AV_CODEC_CAP_AVOID_PROBING, + .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, + .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_VPE, AV_PIX_FMT_NONE }, + .hw_configs = vpe_hw_configs, + .wrapper_name = "vpe", + .bsfs = "hevc_mp4toannexb", +};