From patchwork Mon Oct 21 12:31:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ManojGuptaBonda X-Patchwork-Id: 15888 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 1030D449A7F for ; Mon, 21 Oct 2019 18:18:08 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DF77668B0DD; Mon, 21 Oct 2019 18:18:07 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from hqemgate15.nvidia.com (hqemgate15.nvidia.com [216.228.121.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D360268B06E for ; Mon, 21 Oct 2019 18:18:00 +0300 (EEST) Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 21 Oct 2019 08:18:09 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 21 Oct 2019 08:17:58 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 21 Oct 2019 08:17:58 -0700 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL101.nvidia.com (172.20.187.10) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 21 Oct 2019 12:32:08 +0000 Received: from bondagupta-NVWorkStation.nvidia.com (10.124.1.5) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 21 Oct 2019 12:32:06 +0000 From: ManojGuptaBonda To: Date: Mon, 21 Oct 2019 18:01:38 +0530 Message-ID: <20191021123138.322-3-mbonda@nvidia.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191021123138.322-1-mbonda@nvidia.com> References: <20191021123138.322-1-mbonda@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To DRHQMAIL107.nvidia.com (10.27.9.16) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1571671089; bh=XwAda0ZaTZh9RE0dkxEJvEeCp0pBi4BS2cRXoCkQr/U=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-Originating-IP: X-ClientProxiedBy:Content-Type; b=QPjnKVbeW2khdy0L9ZTKGsRDBe6Eyok+gXY3Byt0jbEcNGt6MyF600KZUI0V9yxmT sSQOzc4cTqE8Z9iEgGkG1A780iAPz4QqSNUFD4q1SJA3jzzrCOXyNFAy0EohBvOXKm UoVhnONMtlB45R231V/tCfqfmgdm8qHB6oU9SefIoXzAWHlmUdpmYEFV18z8WQ0VZY mT+wUAu195V25DxCI4EVvitgHLfL+S6VjCZyBK+tmvb540aeBihxVFVMSqA4unJLrY Xmy8Z8POSgAWpbceyKLc2uXFGbwJTD3rgk6sLgcCk4a5Q5C0PC5ve9a+wdKl7xws/Z s6ItznW3poiRg== Subject: [FFmpeg-devel] [PATCH 2/2] Add decode support for VDPAU VP9. 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: aplattner@nvidia.com, ManojGuptaBonda , mgodse@nvidia.com, ARitger@nvidia.com, philipl@overt.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Populate the codec specific params that need to be passed to VDPAU. --- libavcodec/vdpau_vp9.c | 155 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 153 insertions(+), 2 deletions(-) diff --git a/libavcodec/vdpau_vp9.c b/libavcodec/vdpau_vp9.c index d8f629d135..f1ee4ac5e0 100644 --- a/libavcodec/vdpau_vp9.c +++ b/libavcodec/vdpau_vp9.c @@ -21,7 +21,7 @@ */ #include - +#include "libavutil/pixdesc.h" #include "avcodec.h" #include "internal.h" #include "vp9data.h" @@ -33,7 +33,134 @@ static int vdpau_vp9_start_frame(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { - return 0; + VP9Context *s = avctx->priv_data; + VP9SharedContext *h = &(s->s); + const AVPixFmtDescriptor *pixdesc = av_pix_fmt_desc_get(avctx->sw_pix_fmt); + if (!pixdesc) { + return AV_PIX_FMT_NONE; + } + + VP9Frame pic = h->frames[CUR_FRAME]; + struct vdpau_picture_context *pic_ctx = pic.hwaccel_picture_private; + int i; + + VdpPictureInfoVP9 *info = &pic_ctx->info.vp9; + + info->width = avctx->width; + info->height = avctx->height; + /* fill LvPictureInfoVP9 struct */ + info->lastReference = VDP_INVALID_HANDLE; + info->goldenReference = VDP_INVALID_HANDLE; + info->altReference = VDP_INVALID_HANDLE; + + if (h->refs[h->h.refidx[0]].f && h->refs[h->h.refidx[0]].f->private_ref) { + info->lastReference = ff_vdpau_get_surface_id(h->refs[h->h.refidx[0]].f); + } + if (h->refs[h->h.refidx[1]].f && h->refs[h->h.refidx[1]].f->private_ref) { + info->goldenReference = ff_vdpau_get_surface_id(h->refs[h->h.refidx[1]].f); + } + if (h->refs[h->h.refidx[2]].f && h->refs[h->h.refidx[2]].f->private_ref) { + info->altReference = ff_vdpau_get_surface_id(h->refs[h->h.refidx[2]].f); + } + + info->profile = h->h.profile; + info->frameContextIdx = h->h.framectxid; + info->keyFrame = h->h.keyframe; + info->showFrame = !h->h.invisible; + info->errorResilient = h->h.errorres; + info->frameParallelDecoding = h->h.parallelmode; + + info->subSamplingX = pixdesc->log2_chroma_w; + info->subSamplingY = pixdesc->log2_chroma_h; + + info->intraOnly = h->h.intraonly; + info->allowHighPrecisionMv = h->h.keyframe ? 0 : h->h.highprecisionmvs; + info->refreshEntropyProbs = h->h.refreshctx; + + info->bitDepthMinus8Luma = pixdesc->comp[0].depth - 8; + info->bitDepthMinus8Chroma = pixdesc->comp[1].depth - 8; + + info->loopFilterLevel = h->h.filter.level; + info->loopFilterSharpness = h->h.filter.sharpness; + info->modeRefLfEnabled = h->h.lf_delta.enabled; + + info->log2TileColumns = h->h.tiling.log2_tile_cols; + info->log2TileRows = h->h.tiling.log2_tile_rows; + + info->segmentEnabled = h->h.segmentation.enabled; + info->segmentMapUpdate = h->h.segmentation.update_map; + info->segmentMapTemporalUpdate = h->h.segmentation.temporal; + info->segmentFeatureMode = h->h.segmentation.absolute_vals; + + info->qpYAc = h->h.yac_qi; + info->qpYDc = h->h.ydc_qdelta; + info->qpChDc = h->h.uvdc_qdelta; + info->qpChAc = h->h.uvac_qdelta; + + info->resetFrameContext = h->h.resetctx; + info->mcompFilterType = h->h.filtermode ^ (h->h.filtermode <= 1); + info->uncompressedHeaderSize = h->h.uncompressed_header_size; + info->compressedHeaderSize = h->h.compressed_header_size; + info->refFrameSignBias[0] = 0; + + + for (i = 0; i < FF_ARRAY_ELEMS(info->mbModeLfDelta); i++) + info->mbModeLfDelta[i] = h->h.lf_delta.mode[i]; + + for (i = 0; i < FF_ARRAY_ELEMS(info->mbRefLfDelta); i++) + info->mbRefLfDelta[i] = h->h.lf_delta.ref[i]; + + for (i = 0; i < FF_ARRAY_ELEMS(info->mbSegmentTreeProbs); i++) + info->mbSegmentTreeProbs[i] = h->h.segmentation.prob[i]; + + for (i = 0; i < FF_ARRAY_ELEMS(info->activeRefIdx); i++) { + info->activeRefIdx[i] = h->h.refidx[i]; + info->segmentPredProbs[i] = h->h.segmentation.pred_prob[i]; + info->refFrameSignBias[i + 1] = h->h.signbias[i]; + } + + for (i = 0; i < FF_ARRAY_ELEMS(info->segmentFeatureEnable); i++) { + info->segmentFeatureEnable[i][0] = h->h.segmentation.feat[i].q_enabled; + info->segmentFeatureEnable[i][1] = h->h.segmentation.feat[i].lf_enabled; + info->segmentFeatureEnable[i][2] = h->h.segmentation.feat[i].ref_enabled; + info->segmentFeatureEnable[i][3] = h->h.segmentation.feat[i].skip_enabled; + + info->segmentFeatureData[i][0] = h->h.segmentation.feat[i].q_val; + info->segmentFeatureData[i][1] = h->h.segmentation.feat[i].lf_val; + info->segmentFeatureData[i][2] = h->h.segmentation.feat[i].ref_val; + info->segmentFeatureData[i][3] = 0; + } + + switch (avctx->colorspace) { + default: + case AVCOL_SPC_UNSPECIFIED: + info->colorSpace = 0; + break; + case AVCOL_SPC_BT470BG: + info->colorSpace = 1; + break; + case AVCOL_SPC_BT709: + info->colorSpace = 2; + break; + case AVCOL_SPC_SMPTE170M: + info->colorSpace = 3; + break; + case AVCOL_SPC_SMPTE240M: + info->colorSpace = 4; + break; + case AVCOL_SPC_BT2020_NCL: + info->colorSpace = 5; + break; + case AVCOL_SPC_RESERVED: + info->colorSpace = 6; + break; + case AVCOL_SPC_RGB: + info->colorSpace = 7; + break; + } + + return ff_vdpau_common_start_frame(pic_ctx, buffer, size); + } static const uint8_t start_code_prefix[3] = { 0x00, 0x00, 0x01 }; @@ -41,11 +168,35 @@ static const uint8_t start_code_prefix[3] = { 0x00, 0x00, 0x01 }; static int vdpau_vp9_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size) { + VP9SharedContext *h = avctx->priv_data; + VP9Frame pic = h->frames[CUR_FRAME]; + struct vdpau_picture_context *pic_ctx = pic.hwaccel_picture_private; + + int val; + + val = ff_vdpau_add_buffer(pic_ctx, start_code_prefix, 3); + if (val) + return val; + + val = ff_vdpau_add_buffer(pic_ctx, buffer, size); + if (val) + return val; + return 0; } static int vdpau_vp9_end_frame(AVCodecContext *avctx) { + VP9SharedContext *h = avctx->priv_data; + VP9Frame pic = h->frames[CUR_FRAME]; + struct vdpau_picture_context *pic_ctx = pic.hwaccel_picture_private; + + int val; + + val = ff_vdpau_common_end_frame(avctx, pic.tf.f, pic_ctx); + if (val < 0) + return val; + return 0; }